faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

68 of 141 people (48%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

Passing variables with REQUIRE function (part II)
In http://www.faqts.com/knowledge-base/view.phtml/aid/1205/fid/40 it is stated that require 'copies'

Jan 24th, 2009 09:06
Brad Kint, healthy man, dman, ha mo, Praveen Kumar Kukkapalli, Cinley Rodick, Matt Gregory, Bjarke Bisgaard Blendstrup, http://www.ttnr.org


Since there is no question here, I'm going to assume that you are 
asking what coppies means.
If this is indeed your question, then the answer would be that the php 
script loaded by the require function effectively is parsed in-line 
where the require function is called.
For instance: let's pretend you have 5 lines of code over 2 files:
mytest.phtml
<?
$hoopy="frood";
require("globals.phtml");
$yadda="y pues nada";
?>
globals.phtml
<?
$hoopy="dude";
$yadda="bite me";
?>
functions would be parsed in the following order:
1.) globals.phtml is parsed and loaded with mytest.phtml, parse errors 
will be found before any script execution even if they are in 
globals.phtml
2.) new variable $hoopy is allocated and assigned the value of
"frood"
3.) $hoopy is re-assigned the value of "dude".
4.) $yadda is allocated and assigned the value of "bite me".
5.) $yadda is reassigned the value of "y pues nada";
So, as you see, the script engine runs on 1 file, the conbination of 
the previous two, while the parser sees two files.  Therefore any 
scripting is executed in-line (unless of course you happen to have 
functions, in which case: make sure they aren't within other functions 
or else you will have a parse error.
Rule of thumb: put everything inside of a script which will be included 
in require statements inside of functions.
http://forsakringguide.blogspot.com
http://ghiddeasigurare.blogspot.com
http://guidedelassurance.blogspot.com
http://reiseneuropa1.blogspot.com
http://europadecalatorie.blogspot.com
http://reizeneuropa1.blogspot.com
http://rejsereuropa.blogspot.com
http://consiglibellezza1.blogspot.com
http://www.healthdothealth.com
http://www.healthxhealth.com
http://www.mesotheliomainmesothelioma.com
http://www.healthfirewall.com
http://www.flathealth.com
http://www.healthbodyguard.com
http://www.healthbyhealth.com
http://www.healthment.com
http://www.mesotheliomadown.com
http://www.mesotheliomaout.com
http://www.pickarticle.com