Page 1 of 1

constructor in require/include functions

Posted: Sun Jul 22, 2007 11:08 pm
by rozvinbm_jp
There is a constructor that execute first before require/include function? like __constructor in class...

purpose:
I want to call a function inside the phpfile.php before or upon execution of require('phpfile.php'); to load all the initial variables needed by all php file.

Code: Select all

<?php
//phpfile.php
function constructorfunc (){
    const(WORKINGFOLDER, "c:");
    //.....................
}
?>

<?php
//test.php
require('phpfile.php');
echo WORKINGFOLDER;
?>

Posted: Sun Jul 22, 2007 11:40 pm
by superdezign
When you include / require a file, you are essentially adding all of the code from that file into the current one, so all you have done is made the function available to the first file, not created a constant.

Posted: Sun Jul 22, 2007 11:44 pm
by rozvinbm_jp
yes, I understand..
after require function..
I just call the function next to require function..

Thank you very much..