Thread: include
View Single Post

  #2 (permalink)  
Old 07-24-2007
Rik
 
Posts: n/a
Default Re: include

On Tue, 24 Jul 2007 23:04:46 +0200, Jean Pierre Daviau <Once@WasEno.ugh>
wrote:
> global $autoexec;
> $autoexec = "C:\backJP\autoexec.bat";


> --- snip ----
>
> require_once('paths.inc');
> function updateFichier(){
> if (!$myBool = fopen ($autoexec, "a")) {
> echo "Cant create($autoexec)";
> exit;
> }
>
> The include file is printed on screen
> The function exit with Cant create the file
>
> If I write
> function updateFichier(){
> global $autoexec;
> $autoexec = "autoexec.bat";


This last line is not neccesary

> ......
> it works . . .


You obviously missed something in scopes. I suggest you read up on it:
<http://www.php.net/global>

This very example is explained over there.
--
Rik Wasmus
Reply With Quote