Re: [PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund
Jason Wong wrote:
Possibly:
manual > Using PHP from the command line > -c switch
From the manual:
"The CLI SAPI does not change the current directory to the directory of 
the executed script!"

"Note: The CGI SAPI supports the CLI SAPI behaviour by means of the -C 
switch when run from the command line. "

In other words, it's possible to make the CGI version work like the CLI 
version (using absolute paths only).  There seems to be no support for 
making CLI work like CGI, however.

/Mattias
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Jason Wong
On Tuesday 08 June 2004 04:14, Mattias Thorslund wrote:

> >>What could be the difference that caused this?

As Marek had pointed out the behaviour was changed ...

> >Possibly:
> >
> >  manual > Using PHP from the command line > -c switch
>
> ...except I don't  use the -c switch?

... IIRC just after the change php-cli had a switch that allowed the old 
behaviour, apparently this is not documented in the manual anymore so you 
probably have to use an absolute path.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
The whole world is a scab.  The point is to pick it constructively.
-- Peter Beard
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund
Marek Kilimajer wrote:
cli php uses path relative to your current directory, cgi php uses 
path relative to the executing script.
That IS interesting.  That would explain why:
php /var/www/myproject/util/my-cli-script.php
... will break unless I execute it from that same directory.
I used to be able to do that from anywhere, though - that's why I passed 
the full path to the script.  So it's got to be some configuration 
that's different, or that this behavior has changed.

/Mattias
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Marek Kilimajer
Marek Kilimajer wrote:
Mattias Thorslund wrote:
Hi,
In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line. 
Now I have a new server and I get "no such file or directory" when 
using this construct from the command line.

I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from 
a web browser, just not when I run it from the command line.
The new server has a more recent version of PHP (4.3.4). I don't have 
the php version of the old server but it was on RedHat 9 - now I'm on 
Mandrake 10.

What could be the difference that caused this?
/Mattias
cli php uses path relative to your current directory, cgi php uses path 
relative to the executing script.

You can use
ini_set('include_path', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/'));
at the beginning of your script as workaround
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Marek Kilimajer
Mattias Thorslund wrote:
Hi,
In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line. 
Now I have a new server and I get "no such file or directory" when using 
this construct from the command line.

I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from a 
web browser, just not when I run it from the command line.
The new server has a more recent version of PHP (4.3.4). I don't have 
the php version of the old server but it was on RedHat 9 - now I'm on 
Mandrake 10.

What could be the difference that caused this?
/Mattias
cli php uses path relative to your current directory, cgi php uses path 
relative to the executing script.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Mattias Thorslund

Jason Wong wrote:
On Tuesday 08 June 2004 03:21, Mattias Thorslund wrote:
 

In order to keep configuration files outside the web root I use:
include_once('../config.php');
This used to work also when running php scripts from the command line.
Now I have a new server and I get "no such file or directory" when using
this construct from the command line.
I have worked around this by doing this:
$main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
include_once($main_folder . '/config.php');
The original, simpler construct still works when calling the page from a
web browser, just not when I run it from the command line.
The new server has a more recent version of PHP (4.3.4). I don't have
the php version of the old server but it was on RedHat 9 - now I'm on
Mandrake 10.
What could be the difference that caused this?
   

Possibly:
 manual > Using PHP from the command line > -c switch
 

...except I don't  use the -c switch? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] include_once changed behavior?

2004-06-07 Thread Jason Wong
On Tuesday 08 June 2004 03:21, Mattias Thorslund wrote:

> In order to keep configuration files outside the web root I use:
>
> include_once('../config.php');
>
> This used to work also when running php scripts from the command line.
> Now I have a new server and I get "no such file or directory" when using
> this construct from the command line.
>
> I have worked around this by doing this:
>
> $main_folder = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/..');
> include_once($main_folder . '/config.php');
>
> The original, simpler construct still works when calling the page from a
> web browser, just not when I run it from the command line.
>
> The new server has a more recent version of PHP (4.3.4). I don't have
> the php version of the old server but it was on RedHat 9 - now I'm on
> Mandrake 10.
>
> What could be the difference that caused this?

Possibly:

  manual > Using PHP from the command line > -c switch

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
You have many friends and very few living enemies.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] include_once() isnt!

2004-02-07 Thread Adam Bregenzer
On Tue, 2004-02-03 at 17:04, Rob wrote:
> Ive programmed with C/C++ for years and have recently started to dabble in
> PHP. Ive written a multi-part script for a friend and Ive run into a
> problem.

> Heres where the problem lies. Each component is in a separate file, and when
> I run the script, I get an arror saying I cant re-define the classes.
> Which makes me believe that the include_once() function is trying to include
> the other components even though they are already included. So, does that
> mean that include_once() only works right when it is used in the same file?
> It wont recognise that an include was already included in another include?
> Have I confused you yet? I am.

This is not an answer, but it is a solution.  I don't ever rely on
include_once.  If someone else uses my include files they may not use
include_once.  Instead I use the old C/C++ trick of defines:


I use the following structure for creating unique constants to prevent
collisions:
{projectname}_{classname}( include ? _INC:)

A global class outside my projects:
_CLASS_NAME

The class FooBar in my Rule The World project:
RULE_THE_WORLD_FOO_BAR

The config include in my Rule The World project:
RULE_THE_WORLD_CONFIG_INC


-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Jim lucas

is your isp using a unix machine or windows machine?

if they are using a unix box then your backslash needs to be a forward slash
"/", and if they are using a windows machine, your backslash needs to be
escaped.  -->  "\\"  other wise you are escaping the "b" in blah...

Jim Lucas
- Original Message -
From: "Martin Towell" <[EMAIL PROTECTED]>
To: "'Henry'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, June 11, 2002 4:31 PM
Subject: RE: [PHP] include_once("blah"); vs $blah="blah"; include($blah);


> if that's a direct copy of what you've got, then the parse error's
probably
> to do with the "var" and not the "include_once"
>
> "var" is used only in classes...
>
> -Original Message-
> From: Henry [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 11:11 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> include($blah);
>
>
> I did as you suggest with an interesting result:
>
> include_once "blah.php";
>
> worked
>
> var $blah="blah.php";
> include_once $blah;
>
> gave the following error:
>
> Parse error: parse error in  on line 
>
>
> Where the  is the file that was doing the include!
>
>
>
> Previously include_once($blah) just messed up the scoping and global vars!
>
> Henry
>
> "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Out of curiosity, try
> >
> >  > global $root;
> > $blah="include\blah.php";
> > include_once $blah;
> > ?>
> >
> > & see if it behaves differently (i.e., no parens around the
> > include file name).
> >
> > > -Original Message-
> > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, June 11, 2002 8:15 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > > include($blah);
> > >
> > >
> > > My web hosting company is running  php 4.0.4pl1
> > >
> > > Why should it be that these are different
> > >
> > >  > >
> > > global $root;
> > > include_once("include\blah.php");
> > >
> > > ?>
> > >
> > > and
> > >
> > >  > >
> > > global $root;
> > > $blah="include\blah.php";
> > > include_once($blah);
> > >
> > > ?>
> > >
> > > When I say different I mean;
> > >
> > > 1) global variable are not avaiable in the second version
> > > 2) functions defined in the included file are not
> > > accessable in the
> > > including file.
> > > 3) in both examples the file is included, its just the
> > > scope that seem shot
> > >
> > > Any answers?
> > >
> > > Henry
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Martin Towell

if that's a direct copy of what you've got, then the parse error's probably
to do with the "var" and not the "include_once"

"var" is used only in classes...

-Original Message-
From: Henry [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 11, 2002 11:11 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
include($blah);


I did as you suggest with an interesting result:

include_once "blah.php";

worked

var $blah="blah.php";
include_once $blah;

gave the following error:

Parse error: parse error in  on line 


Where the  is the file that was doing the include!



Previously include_once($blah) just messed up the scoping and global vars!

Henry

"Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Out of curiosity, try
>
>  global $root;
> $blah="include\blah.php";
> include_once $blah;
> ?>
>
> & see if it behaves differently (i.e., no parens around the
> include file name).
>
> > -Original Message-
> > From: Henry [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 11, 2002 8:15 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > include($blah);
> >
> >
> > My web hosting company is running  php 4.0.4pl1
> >
> > Why should it be that these are different
> >
> >  >
> > global $root;
> > include_once("include\blah.php");
> >
> > ?>
> >
> > and
> >
> >  >
> > global $root;
> > $blah="include\blah.php";
> > include_once($blah);
> >
> > ?>
> >
> > When I say different I mean;
> >
> > 1) global variable are not avaiable in the second version
> > 2) functions defined in the included file are not
> > accessable in the
> > including file.
> > 3) in both examples the file is included, its just the
> > scope that seem shot
> >
> > Any answers?
> >
> > Henry
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Jonathan Rosenberg

The examples in the online manual indicate that it is ok to use
the value of a variable for the file name:

http://www.php.net/manual/en/function.include.php

it also shows examples without the parentheses.

Looks like (yet another) PHP bug to me.

Maybe someone more knowledgeable can comment.

> -Original Message-
> From: Henry [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 9:45 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> include($blah);
>
>
> No, the line number is just of the line in the
> includING file of the
> include_once statement.
>
> It's very odd, is this a known limitation of PHP i..e.
> includes cannot have
> variable or functional file names.
>
> i.e.
>
> It's ok to do
> include_once("include/reallyimportantstuff.php");
>
> But it's not ok to do any of the following:
>
> 1)
> $filename="include/reallyimportantstuff.php";
> include_once($filename);
>
> 2)
> include_once("include"."/reallyimportantstuff.php");
>
> 3)
> $root="include";
> include_once($root."/reallyimportantstuff.php");
>
> ?
>
>
> Henry
>
>
> "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Hmmm ... does the line number in the error message point to
> > something in the includeD file?  I.e., might you
> have some error
> > in the file you are including?
> >
> > > -Original Message-
> > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, June 11, 2002 9:11 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> > > include($blah);
> > >
> > >
> > > I did as you suggest with an interesting result:
> > >
> > > include_once "blah.php";
> > >
> > > worked
> > >
> > > var $blah="blah.php";
> > > include_once $blah;
> > >
> > > gave the following error:
> > >
> > > Parse error: parse error in  on line
> > > 
> > >
> > >
> > > Where the  is the file that was doing
> > > the include!
> > >
> > >
> > >
> > > Previously include_once($blah) just messed up the
> > > scoping and global vars!
> > >
> > > Henry
> > >
> > > "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > > Out of curiosity, try
> > > >
> > > >  > > > global $root;
> > > > $blah="include\blah.php";
> > > > include_once $blah;
> > > > ?>
> > > >
> > > > & see if it behaves differently (i.e., no parens
> around the
> > > > include file name).
> > > >
> > > > > -Original Message-
> > > > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Tuesday, June 11, 2002 8:15 AM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > > > > include($blah);
> > > > >
> > > > >
> > > > > My web hosting company is running  php 4.0.4pl1
> > > > >
> > > > > Why should it be that these are different
> > > > >
> > > > >  > > > >
> > > > > global $root;
> > > > > include_once("include\blah.php");
> > > > >
> > > > > ?>
> > > > >
> > > > > and
> > > > >
> > > > >  > > > >
> > > > > global $root;
> > > > > $blah="include\blah.php";
> > > > > include_once($blah);
> > > > >
> > > > > ?>
> > > > >
> > > > > When I say different I mean;
> > > > >
> > > > > 1) global variable are not avaiable in the
> second version
> > > > > 2) functions defined in the included file are not
> > > > > accessable in the
> > > > > including file.
> > > > > 3) in both examples the file is included, its just the
> > > > > scope that seem shot
> > > > >
> > > > > Any answers?
> > > > >
> > > > > Henry
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > PHP General Mailing List (http://www.php.net/)
> > > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Henry

No, the line number is just of the line in the includING file of the
include_once statement.

It's very odd, is this a known limitation of PHP i..e. includes cannot have
variable or functional file names.

i.e.

It's ok to do
include_once("include/reallyimportantstuff.php");

But it's not ok to do any of the following:

1)
$filename="include/reallyimportantstuff.php";
include_once($filename);

2)
include_once("include"."/reallyimportantstuff.php");

3)
$root="include";
include_once($root."/reallyimportantstuff.php");

?


Henry


"Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hmmm ... does the line number in the error message point to
> something in the includeD file?  I.e., might you have some error
> in the file you are including?
>
> > -Original Message-
> > From: Henry [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 11, 2002 9:11 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> > include($blah);
> >
> >
> > I did as you suggest with an interesting result:
> >
> > include_once "blah.php";
> >
> > worked
> >
> > var $blah="blah.php";
> > include_once $blah;
> >
> > gave the following error:
> >
> > Parse error: parse error in  on line
> > 
> >
> >
> > Where the  is the file that was doing
> > the include!
> >
> >
> >
> > Previously include_once($blah) just messed up the
> > scoping and global vars!
> >
> > Henry
> >
> > "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Out of curiosity, try
> > >
> > >  > > global $root;
> > > $blah="include\blah.php";
> > > include_once $blah;
> > > ?>
> > >
> > > & see if it behaves differently (i.e., no parens around the
> > > include file name).
> > >
> > > > -Original Message-
> > > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > > Sent: Tuesday, June 11, 2002 8:15 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > > > include($blah);
> > > >
> > > >
> > > > My web hosting company is running  php 4.0.4pl1
> > > >
> > > > Why should it be that these are different
> > > >
> > > >  > > >
> > > > global $root;
> > > > include_once("include\blah.php");
> > > >
> > > > ?>
> > > >
> > > > and
> > > >
> > > >  > > >
> > > > global $root;
> > > > $blah="include\blah.php";
> > > > include_once($blah);
> > > >
> > > > ?>
> > > >
> > > > When I say different I mean;
> > > >
> > > > 1) global variable are not avaiable in the second version
> > > > 2) functions defined in the included file are not
> > > > accessable in the
> > > > including file.
> > > > 3) in both examples the file is included, its just the
> > > > scope that seem shot
> > > >
> > > > Any answers?
> > > >
> > > > Henry
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Jonathan Rosenberg

Hmmm ... does the line number in the error message point to
something in the includeD file?  I.e., might you have some error
in the file you are including?

> -Original Message-
> From: Henry [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 9:11 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] include_once("blah"); vs $blah="blah";
> include($blah);
>
>
> I did as you suggest with an interesting result:
>
> include_once "blah.php";
>
> worked
>
> var $blah="blah.php";
> include_once $blah;
>
> gave the following error:
>
> Parse error: parse error in  on line
> 
>
>
> Where the  is the file that was doing
> the include!
>
>
>
> Previously include_once($blah) just messed up the
> scoping and global vars!
>
> Henry
>
> "Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > Out of curiosity, try
> >
> >  > global $root;
> > $blah="include\blah.php";
> > include_once $blah;
> > ?>
> >
> > & see if it behaves differently (i.e., no parens around the
> > include file name).
> >
> > > -Original Message-
> > > From: Henry [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, June 11, 2002 8:15 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > > include($blah);
> > >
> > >
> > > My web hosting company is running  php 4.0.4pl1
> > >
> > > Why should it be that these are different
> > >
> > >  > >
> > > global $root;
> > > include_once("include\blah.php");
> > >
> > > ?>
> > >
> > > and
> > >
> > >  > >
> > > global $root;
> > > $blah="include\blah.php";
> > > include_once($blah);
> > >
> > > ?>
> > >
> > > When I say different I mean;
> > >
> > > 1) global variable are not avaiable in the second version
> > > 2) functions defined in the included file are not
> > > accessable in the
> > > including file.
> > > 3) in both examples the file is included, its just the
> > > scope that seem shot
> > >
> > > Any answers?
> > >
> > > Henry
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Henry

I did as you suggest with an interesting result:

include_once "blah.php";

worked

var $blah="blah.php";
include_once $blah;

gave the following error:

Parse error: parse error in  on line 


Where the  is the file that was doing the include!



Previously include_once($blah) just messed up the scoping and global vars!

Henry

"Jonathan Rosenberg" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Out of curiosity, try
>
>  global $root;
> $blah="include\blah.php";
> include_once $blah;
> ?>
>
> & see if it behaves differently (i.e., no parens around the
> include file name).
>
> > -Original Message-
> > From: Henry [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 11, 2002 8:15 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] include_once("blah"); vs $blah="blah";
> > include($blah);
> >
> >
> > My web hosting company is running  php 4.0.4pl1
> >
> > Why should it be that these are different
> >
> >  >
> > global $root;
> > include_once("include\blah.php");
> >
> > ?>
> >
> > and
> >
> >  >
> > global $root;
> > $blah="include\blah.php";
> > include_once($blah);
> >
> > ?>
> >
> > When I say different I mean;
> >
> > 1) global variable are not avaiable in the second version
> > 2) functions defined in the included file are not
> > accessable in the
> > including file.
> > 3) in both examples the file is included, its just the
> > scope that seem shot
> >
> > Any answers?
> >
> > Henry
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] include_once("blah"); vs $blah="blah"; include($blah);

2002-06-11 Thread Jonathan Rosenberg

Out of curiosity, try



& see if it behaves differently (i.e., no parens around the
include file name).

> -Original Message-
> From: Henry [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 11, 2002 8:15 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] include_once("blah"); vs $blah="blah";
> include($blah);
>
>
> My web hosting company is running  php 4.0.4pl1
>
> Why should it be that these are different
>
> 
> global $root;
> include_once("include\blah.php");
>
> ?>
>
> and
>
> 
> global $root;
> $blah="include\blah.php";
> include_once($blah);
>
> ?>
>
> When I say different I mean;
>
> 1) global variable are not avaiable in the second version
> 2) functions defined in the included file are not
> accessable in the
> including file.
> 3) in both examples the file is included, its just the
> scope that seem shot
>
> Any answers?
>
> Henry
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] include_once()

2002-03-19 Thread Martin Towell

is it possible to send the code - or snippets of the code - so that someone
might be able to spot the error

something that you might want to look at is whether the included file has a
parse error - the set up in this company allows the "parent" script to
continue to run, even if the "child" script has an error (dunno if this is a
php setting or it's default behaviour???)

-Original Message-
From: Mauricio Cuenca [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 20, 2002 11:14 AM
To: anders nawroth; [EMAIL PROTECTED]
Subject: Re: [PHP] include_once()


Yes,

I read the documentation and took close note to include the start and end
tags... 

Thanks,

__
Mauricio Cuenca

- Original Message -
From: "anders nawroth" <>
To: "Mauricio Cuenca" ; <[EMAIL PROTECTED]>
Sent: Tuesday, March 19, 2002 2:26 PM
Subject: Re: [PHP] include_once()


> Have you put 
> Anders
>
> - Ursprungligt meddelande -
> Från: "Mauricio Cuenca" <>
> Till: <>
> Skickat: den 19 mars 2002 17:43
> Ämne: [PHP] include_once()
>
>
> > Hello,
> >
> > I have a very long script with several functions in it. I wanted to
split
> > the script into several files, so I created two sub-scripts and one main
> > script. This is the code from the main script:
> >
> >  >
> > include_once("sub_script_1.php");
> > incude_once("sub_script_2.php");
> >
> > $temp = MyFunction();
> >
> > ?>
> >
> > MyFunction() is contained in the file "sub_script_1.php" which is
properly
> > enclosed with valid PHP start and end tags.
> >
> > But When I try to run the main script, I get this error:
> > Fatal error: Call to undefined function: MyFunction()in /main_script.php
on
> > line 4.
> >
> > How can I properly "divide" my script into several ones ???
> >
> > TIA,



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once()

2002-03-19 Thread Mauricio Cuenca

No I haven't.

Wouldn't this affect my entire web site ?
I just need to include the files into a single script.

Thanks,
__
Mauricio Cuenca

- Original Message -
From: "Neil Freeman"
To: "Mauricio Cuenca"
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, March 19, 2002 12:30 PM
Subject: Re: [PHP] include_once()


> Have you remembered to set up PHP's include_path to point to the area
where
> your scripts are located?
>
> Neil
>
> Mauricio Cuenca wrote:
>
> > Hello,
> >
> > I have a very long script with several functions in it. I wanted to
split
> > the script into several files, so I created two sub-scripts and one main
> > script. This is the code from the main script:
> >
> >  >
> > include_once("sub_script_1.php");
> > incude_once("sub_script_2.php");
> >
> > $temp = MyFunction();
> >
> > ?>
> >
> > MyFunction() is contained in the file "sub_script_1.php" which is
properly
> > enclosed with valid PHP start and end tags.
> >
> > But When I try to run the main script, I get this error:
> > Fatal error: Call to undefined function: MyFunction()in /main_script.php
on
> > line 4.
> >
> > How can I properly "divide" my script into several ones ???
> >
> > TIA,
> >



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once()

2002-03-19 Thread Mauricio Cuenca

Yes,

I read the documentation and took close note to include the start and end
tags... 

Thanks,

__
Mauricio Cuenca

- Original Message -
From: "anders nawroth" <>
To: "Mauricio Cuenca" ; <[EMAIL PROTECTED]>
Sent: Tuesday, March 19, 2002 2:26 PM
Subject: Re: [PHP] include_once()


> Have you put 
> Anders
>
> - Ursprungligt meddelande -
> Från: "Mauricio Cuenca" <>
> Till: <>
> Skickat: den 19 mars 2002 17:43
> Ämne: [PHP] include_once()
>
>
> > Hello,
> >
> > I have a very long script with several functions in it. I wanted to
split
> > the script into several files, so I created two sub-scripts and one main
> > script. This is the code from the main script:
> >
> >  >
> > include_once("sub_script_1.php");
> > incude_once("sub_script_2.php");
> >
> > $temp = MyFunction();
> >
> > ?>
> >
> > MyFunction() is contained in the file "sub_script_1.php" which is
properly
> > enclosed with valid PHP start and end tags.
> >
> > But When I try to run the main script, I get this error:
> > Fatal error: Call to undefined function: MyFunction()in /main_script.php
on
> > line 4.
> >
> > How can I properly "divide" my script into several ones ???
> >
> > TIA,



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once()

2002-03-19 Thread anders nawroth

Have you put 
Till: <[EMAIL PROTECTED]>
Skickat: den 19 mars 2002 17:43
Ämne: [PHP] include_once()


> Hello,
> 
> I have a very long script with several functions in it. I wanted to split
> the script into several files, so I created two sub-scripts and one main
> script. This is the code from the main script:
> 
>  
> include_once("sub_script_1.php");
> incude_once("sub_script_2.php");
> 
> $temp = MyFunction();
> 
> ?>
> 
> MyFunction() is contained in the file "sub_script_1.php" which is properly
> enclosed with valid PHP start and end tags.
> 
> But When I try to run the main script, I get this error:
> Fatal error: Call to undefined function: MyFunction()in /main_script.php on
> line 4.
> 
> How can I properly "divide" my script into several ones ???
> 
> TIA,
> 
> __
> Mauricio Cuenca
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once()

2002-03-19 Thread Neil Freeman

Have you remembered to set up PHP's include_path to point to the area where
your scripts are located?

Neil

Mauricio Cuenca wrote:

> Hello,
>
> I have a very long script with several functions in it. I wanted to split
> the script into several files, so I created two sub-scripts and one main
> script. This is the code from the main script:
>
> 
> include_once("sub_script_1.php");
> incude_once("sub_script_2.php");
>
> $temp = MyFunction();
>
> ?>
>
> MyFunction() is contained in the file "sub_script_1.php" which is properly
> enclosed with valid PHP start and end tags.
>
> But When I try to run the main script, I get this error:
> Fatal error: Call to undefined function: MyFunction()in /main_script.php on
> line 4.
>
> How can I properly "divide" my script into several ones ???
>
> TIA,
>
> __
> Mauricio Cuenca
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--

 Email:  [EMAIL PROTECTED]
 [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] include_once

2001-02-28 Thread Hardy Merrill

Solved - I was changing a copy of the code that the webserver
was NOT looking at.  "include_once" works fine.

Appologies.

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

Hardy Merrill [[EMAIL PROTECTED]] wrote:
> Redhat 6.1 Linux
> PHP 4.0.4pl1
> Apache 1.3.14
> 
> Anyone using "include_once"?  I'm executing a PHP script "A.php"
> by referring to it in my Netscape browser URL - script A.php does
> an include_once of "B.php" - B.php contains a database connect
> function that does a connect to an Oracle database.
> 
> I purposely brought down the Oracle database to force a connect
> error.  I have an "error_log" statement in the connect failure
> that prints to our webserver error log - the connect error was
> reported fine.  ***THEN, I added more text to the error_log
> output for that connect failure, but the new text is *NOT*
> appearing in any subsequent connect failures.
> 
> Why won't my new text appear in the error?  I've tried changing
> the "include_once" to "include", and the same thing happened.
> I even tried restarting the webserver, but it had no affect.
> 
> This is driving me nuts!  Help please.
> 
> TIA.
> 
> -- 
> Hardy Merrill
> Mission Critical Linux, Inc.
> http://www.missioncriticallinux.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]