Reply
echoing a file which included php code
Old 07-29-2004, 07:26 PM echoing a file which included php code
Average Talker

Posts: 15
Trades: 0
Hello - I am trying to read the contents of a local file, and echo the contents. I'm able to do this using the various FILE functions, but I'm stuck on the following issue ...

My resulting echo is echoing the embedded PHP code literally.

For example my called "file.inc" has the following contents with embedded PHP:

<? $word = "hello"; ?>
He said <?=$word?> to the dog.




I want to read the contents of the above file and echo it back. I want it to display the processed "He said hello to the dog" and not the literal code which resides in the file.

I tried doing a simple command

echo include ("file.inc");

but that produced:

"He said hello to the dog1" <---- note the appended 1

I'm figuring the 1 is returned because the include worked and thus was true.


Hoping all of the above makes sense ... I'm trying to echo back the contents of a file, but also want those contents to execute the embedded PHP code, not just parrot it back.


Thanking the responder in advance ...
new_PHP_er is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 07-29-2004, 07:29 PM
Republikin's Avatar
Defies a Status

Posts: 3,190
Trades: 3
use file()
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-29-2004, 07:38 PM
Christopher's Avatar
Iced Cap

Posts: 3,113
Location: Toronto, Ontario
Trades: 0
new_PHP_er, just simply use include(). You don't need to echo it out.

PHP Code:
include('file.inc'); // he said hello to the dog 
Quote:
I'm figuring the 1 is returned because the include worked and thus was true.
Yes, you are correct.
Christopher is offline
Reply With Quote
View Public Profile
 
Old 07-30-2004, 12:38 AM Thanks ...
Average Talker

Posts: 15
Trades: 0
Sems so obvious now. Thanks again.
new_PHP_er is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to echoing a file which included php code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.09452 seconds with 13 queries