This is a discussion on "Syntax to include a file as a variable???" within the PHP Forum section. This forum, and the thread "Syntax to include a file as a variable??? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Syntax to include a file as a variable???
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Syntax to include a file as a variable???
I'm appending a few lines of text to a file. The text may change later, so I want to make it an include for easy edit.
What is the right syntax to include a file as a variable? I can declare straight text and it works fine. But how can I include some text from a file?
|
|
|
|
#2
|
|||
|
|||
|
Re: Syntax to include a file as a variable???
You can try
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
|
|
#3
|
|||
|
|||
|
Re: Syntax to include a file as a variable???
I'm don't know why, but that code only appends the word "Array" to the file.
Is file() a php function? Or do you have to define it as one first? |
|
#4
|
|||
|
|||
|
Re: Syntax to include a file as a variable???
file() is a PHP function. Are you sure you have copy-pasted the code properly? Esp that [$i] in file[$i]? It works here!
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
|
|
#5
|
|||
|
|||
|
Re: Syntax to include a file as a variable???
Pretty sure. But I got the include to work like so...
|
|
#6
|
||||
|
||||
|
Re: Syntax to include a file as a variable???
The below is for php5+
If you want to execute PHP code in another script you can do:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#7
|
||||
|
||||
|
Re: Syntax to include a file as a variable???
Quote:
file_put_contents is still not available in PHP 4 - it takes the contents of a file and prints it straight out.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
#8
|
||||
|
||||
|
Re: Syntax to include a file as a variable???
Ah right, thanks for the correction.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Syntax error with Ajax file reading | Paramiliar | JavaScript Forum | 0 | Aug 12th, 2007 16:48 |
| How do I add new variable in a .TPL file | toasty | PHP Forum | 1 | Oct 9th, 2006 18:27 |
| Session include file | manzil | PHP Forum | 1 | Aug 6th, 2006 16:34 |
| Syntax of import/export variable | MojoP | JavaScript Forum | 0 | Aug 15th, 2005 17:57 |
| Question about my navigation include file | James-Clarke | Classic ASP | 3 | May 17th, 2005 14:36 |