Attention: PROnetworks has upgraded our forum from phpbb2 to phpbb3!!

Please head over to our new converted forum at: http://www.pronetworks.org/forums/

This old forum will remain 'read-only' until approximately February 2009. We look forward to seeing you at the new forum!
Author Message
toddthegeek
PostPosted: Fri Jan 25, 2008 11:24 pm Reply with quote

PRO Level 7
 
 


Joined: 04 Nov 2004
Posts: 253
Location: chicago
Hi all,

I don't know if there is a way to do this, but I would really appreciate it if you guys know of a way to do this.

I want to have some php code --lets say in index.php-- setup to read the code in another file --say code.php--. The catch is that code.php well contains some php code that i want to be ran in index.php.

Is there any way to do this? If you don't understand the questions this might help.

Index.php is my main page, and on it I want a sidebar --maybe a simple calendar and a login field (it may change on each page so I'd want one file to be linked to all pages). I put the HTML/PHP for the sidebar in a file called code.php. Index.php will read code.php and just display all the text without running the php code.

I'm fairly new at php so I don't know if there is a way to do this or perhaps a better way to accomplish what I want.

Any ideas? Thanks.
 
Back to top
c0ldfyr3
Andrew J Gurklies
PostPosted: Fri Jan 25, 2008 11:54 pm Reply with quote

PRO BRONZE
 
 


Joined: 02 May 2004
Posts: 3067
Location: 127.0.0.1
i do believe you could use...

Code:

include('code.php');
 
Back to top
jbullard
Jason Bullard
PostPosted: Sat Jan 26, 2008 4:34 am Reply with quote

VP - Software
 
 


Joined: 06 Jun 2004
Posts: 3304
Location: Utah
You can use different options actually.

include continues executing code no matter what; even if an error is evaluated whereas require does not. It will actually prevent the rest of the code from running.

But it is really up to how you want errors to be handled if one is encountered.
 
Back to top
toddthegeek
PostPosted: Sat Jan 26, 2008 6:17 pm Reply with quote

PRO Level 7
 
 


Joined: 04 Nov 2004
Posts: 253
Location: chicago
ah ha. i was trying to think of a complex way of solving the problem when all i needed was a simple one.

I'll give that a shot. Thanks guys!!
 
Back to top
Back to top
Index >> Webmaster Domain & Code Room >> read php code from file and run it

Page 1 of 1

 


Tired of the Ads? Registered users have 80% less adverts.