Forum Moderators: coopster

Message Too Old, No Replies

delaying Include execution

         

defanjos

7:11 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I usually work with ASP and am new to PHP. It seems like includes behave differently. In PHP the include is executed before the page, in ASP is the other way around.

Is it possible to execute the contents of an include after the page loads?

I want to be able to "grab" a variable present in the page from within the include but am unable to do it.

Thanks for any pointers.

d40sithui

7:26 pm on Nov 7, 2007 (gmt 0)

10+ Year Member



from my understanding, include is executed like any other function/statement whihc is sequentially from the top and going down the page.

eelixduppy

7:40 pm on Nov 7, 2007 (gmt 0)




I want to be able to "grab" a variable present in the page from within the include but am unable to do it.

You should be able to unless you are including the file as an url in which case the code will be interpreted before it is included.

How are you including the file? Can you give us an example?

[edited by: eelixduppy at 9:43 pm (utc) on Nov. 7, 2007]

defanjos

8:21 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>You should be able to unless you are include the file as an url in which case the code will be interpreted before it is included.

Bingo, that is it. I was including the file like:
<?php include('http://www.mysite.com/folder1/includes/myinclude.php');?>

I changed it to <?php include('../includes/myinclude.php');?>, and it works.

Thank you very much

eelixduppy

9:52 pm on Nov 7, 2007 (gmt 0)



Glad you resolved your problem :)