Re: [PHP] require_once

2010-10-19 Thread chris h

  I'm having a problem including files using Zend Framework. I have in a
 controller file this


Jim why not use the Zend autoloader?


Chris.


Re: [PHP] require_once

2010-10-19 Thread jim
 I am following an example. Also, doesn't that require the class name 
to be something like models_members?


Jim

On 10/19/2010 09:40 AM, chris h wrote:


 I'm having a problem including files using Zend Framework. I have
in a controller file this


Jim why not use the Zend autoloader?


Chris.




Re: [PHP] require_once

2010-10-19 Thread chris h
I see!

Yes using an autoloader typically requires following a naming convention for
your classes (though you can get around it by defining your own naming
rules).  I didn't care for it much at first, but it's nice that class names
are explicit (less confusion when you have several) and not worrying about
requiring all your files is a plus.


Chris.

On Tue, Oct 19, 2010 at 10:00 AM, jim jbw2...@earthlink.net wrote:

  I am following an example. Also, doesn't that require the class name to be
 something like models_members?

 Jim


 On 10/19/2010 09:40 AM, chris h wrote:

   I'm having a problem including files using Zend Framework. I have in a
 controller file this


  Jim why not use the Zend autoloader?


  Chris.





[PHP] require_once

2010-10-18 Thread jim
 I'm having a problem including files using Zend Framework. I have in a 
controller file this


require_once models/Member.php; and it doesn't work ,nor does

require_once ../models/Member.php;

Anyone know what's going on with this?

Jim W.



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



Re: [PHP] require_once

2010-10-18 Thread 惠新宸


hi:

print_r(get_include_path());

thanks;

Best regards

惠新宸 Xinchen Hui
http://www.laruence.com/

On 10/19/2010 10:46, jim wrote:

   I'm having a problem including files using Zend Framework. I have in a
controller file this

require_once models/Member.php; and it doesn't work ,nor does

require_once ../models/Member.php;

Anyone know what's going on with this?

Jim W.



--
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] require_once

2010-09-01 Thread David Mehler
Hello,
I've got probably a simple question on require_once. I've got a file
that has require_once at the top of it pulling in another file of
functions. Later on in this file I've got another require_once
bringing in a second file. In this second file I have a function call
to a function defined in the first files' top require_once functions
file. I'm getting a call to undefined function.
Should I change he require_once to require at the top of the first
file to fix? I thought require_once meant it was in that file and
anything pulled in later?
Thanks.
Dave.

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



Re: [PHP] require_once

2010-09-01 Thread Peter Lind
On 1 September 2010 08:00, David Mehler dave.meh...@gmail.com wrote:
 Hello,
 I've got probably a simple question on require_once. I've got a file
 that has require_once at the top of it pulling in another file of
 functions. Later on in this file I've got another require_once
 bringing in a second file. In this second file I have a function call
 to a function defined in the first files' top require_once functions
 file. I'm getting a call to undefined function.
 Should I change he require_once to require at the top of the first
 file to fix? I thought require_once meant it was in that file and
 anything pulled in later?
 Thanks.
 Dave.

The file is included properly, otherwise your script would halt.
You're likely looking at an issue of scope: the functions might be
included in a scope you don't expect them to be.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



[PHP] require_once failure

2009-06-25 Thread ste.paole...@tiscali.it
Hi all, I'm a php programmer an I found an anomaly.. it could be a bug. 
On Mac Os all goes right but on debian enviroment there are some 
problems:
Suppose I've the file /home/ste/test.php containing the 
following line:
 ?php
set_include_path('/usr/share/php');
require_once

'PHPUnit/Extensions/Database/Testcase.php';

also suppose that file 
/usr/share/php/PHPUnit/Extensions/Database/Testcase.php really exist.


If I open a shell and runs the script I've the following fatal error:


s...@debian:~$ php -v
PHP 5.2.6-1+lenny2 with Suhosin-Patch 0.9.6.2

(cli) (built: Jan 26 2009 22:41:04)
Copyright (c) 1997-2008 The PHP

Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

with Zend Debugger v5.2.15, Copyright (c) 1999-2008, by Zend

Technologies

s...@debian:~$ php test.php
Warning: require_once

(PHPUnit/Extensions/Database/Testcase.php): failed to open stream: No

such file or directory in /home/ste/test.php on line 3

Fatal error:

require_once(): Failed opening required

'PHPUnit/Extensions/Database/Testcase.php'

(include_path='/usr/share/php') in /home/ste/ste.php on line 3




Someone can help me? Why on Mac Os there are no problems?
Thanks all


Con Tutto Incluso chiami e navighi senza limiti a soli 14,95 euro al mese. 
Gratis la Sim Tiscali Mobile con 50 euro di traffico! L’offerta è valida solo 
se attivi entro il 25/06/09

http://abbonati.tiscali.it/promo/tuttoincluso/

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



RE: [PHP] require_once failure

2009-06-25 Thread Jay Blanchard
[snip] s...@debian:~$ php test.php
Warning: require_once

(PHPUnit/Extensions/Database/Testcase.php): failed to open stream: No

such file or directory in /home/ste/test.php on line 3

Fatal error:

require_once(): Failed opening required

'PHPUnit/Extensions/Database/Testcase.php'

(include_path='/usr/share/php') in /home/ste/ste.php on line 3
[/snip]

The first thing I would do is check the permissions on the file to be
included. If those are OK modify your script to give the absolute path
to the file.

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



Re: [PHP] require_once failure

2009-06-25 Thread Michael A. Peters

ste.paole...@tiscali.it wrote:
Hi all, I'm a php programmer an I found an anomaly.. it could be a bug. 
On Mac Os all goes right but on debian enviroment there are some 
problems:
Suppose I've the file /home/ste/test.php containing the 
following line:

 ?php
set_include_path('/usr/share/php');
require_once

'PHPUnit/Extensions/Database/Testcase.php';

also suppose that file 
/usr/share/php/PHPUnit/Extensions/Database/Testcase.php really exist.



If I open a shell and runs the script I've the following fatal error:


s...@debian:~$ php -v
PHP 5.2.6-1+lenny2 with Suhosin-Patch 0.9.6.2

(cli) (built: Jan 26 2009 22:41:04)
Copyright (c) 1997-2008 The PHP

Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

with Zend Debugger v5.2.15, Copyright (c) 1999-2008, by Zend

Technologies

s...@debian:~$ php test.php
Warning: require_once

(PHPUnit/Extensions/Database/Testcase.php): failed to open stream: No

such file or directory in /home/ste/test.php on line 3

Fatal error:

require_once(): Failed opening required

'PHPUnit/Extensions/Database/Testcase.php'

(include_path='/usr/share/php') in /home/ste/ste.php on line 3




Someone can help me? Why on Mac Os there are no problems?
Thanks all


Are you sure it isn't in /usr/share/pear ??
I don't know Debian's layout, but CentOS/Fedora put pear stuff in 
/usr/share/pear - NOT /usr/share/php


I bet if you comment out the explicit setting if the include path it 
would work, the path to pear is usually in the default include path 
defined in the php.ini file on Linux installs.


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



Re: [PHP] require_once failure

2009-06-25 Thread Daniel Brown
On Thu, Jun 25, 2009 at 07:26,
ste.paole...@tiscali.itste.paole...@tiscali.it wrote:

 Someone can help me? Why on Mac Os there are no problems?

Start by making sure that the file is there and is readable by the
user as which you are logged in.  Execute the command:

ls -l /usr/share/php/PHPUnit/Extensions/Database/Testcase.php

My guess is that it's not there, but if it is, that it is not readable.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



RE: [PHP] PHP require_once() opens some files but not others in same library

2009-04-07 Thread Henning Glatter-Gotz
 Maybe ask on the zend list - 
 http://framework.zend.com/community/resources since they will be 
 familiar with it.

 Still sounds like a url is being used for a require/include but *shrug*.

The issue resolved itself when I moved the domain to a different server. I
had to do this for other reasons and now the previously described issues no
longer occur.

Cheers
Henning



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



[PHP] PHP require_once() opens some files but not others in same library

2009-04-06 Thread hglattergotz

Hello,

I have a very simple form created with the help of Zend Framework with only
one text box that loads fine on my two development machines (Win and Linux)
but generates 2 warnings and a fatal error on my production Linux machine.

For this test I am using PHP 5.2.3 and I added the path to the Zend
Framework Library in my php.ini file. File permissions are good (everyone
can at least read).

I have added the PHP code here for completeness, but it might not be
important for this problem. The error messages below are what I really need
help with.

Contents of formtest.php:
   require_once('formclass.php');

   $f = new ZDF();
   $request = new Zend_Controller_Request_Http();
   $view = new Zend_View( array( 'basePath' = '/templates' ) );
   $view-addHelperPath( 'Zend/View/Helper/', 'Zend_View_Helper' );
   echo $f-render( $view );

Contents of formclass.php
   require_once('Zend/Form.php');
   require_once('Zend/View.php');
   require_once('Zend/Controller/Request/Http.php');

   class ZDF extends Zend_Form
   {
  public function init()
  {
 $this-setAction( 'testform1.php' );
 $this-setMethod( 'post' );
 $this-setAttrib( 'id', 'testform' );

 $e = $this-createElement( 'Text',
'firstname',
array( 'label' = 'First name',
   'required' = 'true',
   'invalidMessage' = 'This field
cannot be left blank.' ) );
 $this-addElement($e);

 $this-addElement('submit', 'Submit', array('label' = 'Submit'));
  }

  public function setView(Zend_View_Interface $view) {
 parent::setView($view);
 foreach ($this as $item) {
$item-setView($view);
 }
 return $this;
  }
   }

Here are the warnings and the error that I get:

Warning: Zend_Loader_PluginLoader::require_once()
[function.Zend-Loader-PluginLoader-require-once]: couldn't resolve host name
in /usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389

Warning:
Zend_Loader_PluginLoader::require_once(Zend/Loader/PluginLoader/Exception.php)
[function.Zend-Loader-PluginLoader-require-once]: failed to open stream:
Success in /usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on
line 389

Fatal error: Zend_Loader_PluginLoader::require_once() [function.require]:
Failed opening required 'Zend/Loader/PluginLoader/Exception.php'
(include_path='.:/usr/local/php5/lib/php:/usr/local/php5/lib/php/library')
in /usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389

Please note that the script got to line 389 of the PluginLoader.php file,
which means that it was able to load that file, which furthermore indicates
that the include path is correct and working. However, it cannot open the
file Zend/Loader/PluginLoader/Exception.php.
This file exists and has read permissions for everyone.
Another really perplexing issue is that when I add some debug code in the
PluginLoader.php file just before line 389 and call
file_exists('/usr/local/php5/lib/php/library/Zend/Loader/PluginLoader/Exception.php')
it returns false. When I open a console and copy and paste this absolute
path into a call to vi for example, it opens the file. So the file exists,
php was able to open the PluginLoader.php at an earlier point file but now
all of a sudden it cannot open a file that clearly exists.

when I hard code the absolute path on line 389 the first warning changes to
Warning: Zend_Loader_PluginLoader::require_once()
[function.Zend-Loader-PluginLoader-require-once]: URL using bad/illegal
format or missing URL in
/usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389

My first reaction was that this is a permissions problem, but even after
doing a chmod -R 777 on the Zend directory it does not work. My next guess
was open file limit, but my hosting companies support told me the limit is
set to 4000 and it is not even coming close to that.

Any ideas?
Thanks
Henning 
-- 
View this message in context: 
http://www.nabble.com/PHP-require_once%28%29-opens-some-files-but-not-others-in-same-library-tp22912504p22912504.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] PHP require_once() opens some files but not others in same library

2009-04-06 Thread Chris


snip


Here are the warnings and the error that I get:

Warning: Zend_Loader_PluginLoader::require_once()
[function.Zend-Loader-PluginLoader-require-once]: couldn't resolve host name
in /usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389


Why is this trying to load something via http (or ftp even)?

couldn't resolve hostname is not something you get when you include or 
require a file locally.



when I hard code the absolute path on line 389 the first warning changes to
Warning: Zend_Loader_PluginLoader::require_once()
[function.Zend-Loader-PluginLoader-require-once]: URL using bad/illegal
format or missing URL in
/usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389


What is the absolute path you are putting in? It looks like a url 
according to the message.


It should be a file path:

/usr/local/php5/lib/php/library/Zend/blah/blah/blah

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] PHP require_once() opens some files but not others in same library

2009-04-06 Thread Chris

Henning Glatter-Gotz wrote:

Chris,

At no point am I using a URL.
Under normal circumstances the code includes (require_once) things like
Zend/Loader/blablabla. Because this does not resolve in the local
directory it is supposed to consult the PHP include_path to look this up.
And it does this successfully up to a point.
The full path is /usr/local/php5/lib/php/library/Zend/Loader/blablabla.

When I say up to a point I mean that my code includes files in Zend/...
and it eventually ends up in the file Zend/Loader/PluginLoader.php. So the
whole include mechanism worked up to this point. However in this
PluginLoader.php file on line 389 it calls
require_once(Zend/Loader/PluginLoader/Exception.php) and this is when
things go bad.

To see if it makes a difference I modified line 389 to read
require_once(/usr/local/php5/lib/php/library/Zend/Loader/PluginLoader/Excep
tion.php) and got the slightly different error as described in my original
post.


Maybe ask on the zend list - 
http://framework.zend.com/community/resources since they will be 
familiar with it.


Still sounds like a url is being used for a require/include but *shrug*.

--
Postgresql  php tutorials
http://www.designmagick.com/


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



RE: [PHP] PHP require_once() opens some files but not others in same library

2009-04-06 Thread Henning Glatter-Gotz
Chris,

At no point am I using a URL.
Under normal circumstances the code includes (require_once) things like
Zend/Loader/blablabla. Because this does not resolve in the local
directory it is supposed to consult the PHP include_path to look this up.
And it does this successfully up to a point.
The full path is /usr/local/php5/lib/php/library/Zend/Loader/blablabla.

When I say up to a point I mean that my code includes files in Zend/...
and it eventually ends up in the file Zend/Loader/PluginLoader.php. So the
whole include mechanism worked up to this point. However in this
PluginLoader.php file on line 389 it calls
require_once(Zend/Loader/PluginLoader/Exception.php) and this is when
things go bad.

To see if it makes a difference I modified line 389 to read
require_once(/usr/local/php5/lib/php/library/Zend/Loader/PluginLoader/Excep
tion.php) and got the slightly different error as described in my original
post.

I have tried to find something about this type of error on Google, but most
search results are pages of web sites that are written in php that at the
time of indexing displayed this error. The sites don't actually have
anything to do with PHP development.

I have even gone as far as downloading the php source code to try and see if
I can figure out why this type of error world be caused. No luck yet.

Cheers
Henning

-Original Message-
From: Chris [mailto:dmag...@gmail.com] 
Sent: Monday, April 06, 2009 11:05 PM
To: hglattergotz
Cc: php-general@lists.php.net
Subject: Re: [PHP] PHP require_once() opens some files but not others in
same library


snip

 Here are the warnings and the error that I get:
 
 Warning: Zend_Loader_PluginLoader::require_once()
 [function.Zend-Loader-PluginLoader-require-once]: couldn't resolve host
name
 in /usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line
389

Why is this trying to load something via http (or ftp even)?

couldn't resolve hostname is not something you get when you include or 
require a file locally.

 when I hard code the absolute path on line 389 the first warning changes
to
 Warning: Zend_Loader_PluginLoader::require_once()
 [function.Zend-Loader-PluginLoader-require-once]: URL using bad/illegal
 format or missing URL in
 /usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389

What is the absolute path you are putting in? It looks like a url 
according to the message.

It should be a file path:

/usr/local/php5/lib/php/library/Zend/blah/blah/blah

-- 
Postgresql  php tutorials
http://www.designmagick.com/


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



RE: [PHP] PHP require_once() opens some files but not others in same library

2009-04-06 Thread Henning Glatter-Gotz
snip

Maybe ask on the zend list - 
http://framework.zend.com/community/resources since they will be 
familiar with it.

Still sounds like a url is being used for a require/include but *shrug*.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

I did ask on the Nabble Zend list but have not gotten a reply. Will try the
official Zend list next.
I am pretty sure that the library is not using a URL since I get this
message 

Warning: Zend_Loader_PluginLoader::require_once()
[function.Zend-Loader-PluginLoader-require-once]: URL using bad/illegal
format or missing URL in
/usr/local/php5/lib/php/library/Zend/Loader/PluginLoader.php on line 389

When I hard code the full path.

Very odd.
Thanks for taking a stab at this.

Henning


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



Re: [PHP] require_once dying silently

2008-04-09 Thread Zoltán Németh

Richard S. Crawford írta:

Hi, everyone.

This one's been driving me bonkers for an hour now.  Anyone have any idea
why require_once would be dying silently in the script below?



$CFG-dirroot   = /home/rcrawford/public_html/tanktrunk/tanktrunk;
$CFG-dataroot  = $CFG-dirroot.'/moodledata';

require_once($CFG-dirroot/lib/setup.php);


the above won't work, as the parser will try to interpret $CFG and put 
it in the string first, then go ahead.

try this:
require_once($CFG-dirroot./lib/setup.php);
or this:
require_once({$CFG-dirroot}/lib/setup.php);

greets,
Zoltán Németh




I've confirmed that the file setup.php exists and is readable.  I've got
error_reporting in php.ini set to E_ALL.  I'm running Apache 2 and PHP5 on
Kubuntu 7.10.  Nothing shows up in my apache error log, and PHP itself
produces absolutely no output, even though it will produce output galore
when I put in a deliberate syntax error.

I've also tried:


require_once($CFG-dirroot./lib/setup.php);


but this didn't help.

Any assistance at all would be greatly appreciated.




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



Re: [PHP] require_once dying silently

2008-04-09 Thread Aschwin Wesselius

Richard S. Crawford wrote:

Hi, everyone.

This one's been driving me bonkers for an hour now.  Anyone have any idea
why require_once would be dying silently in the script below?



$CFG-dirroot   = /home/rcrawford/public_html/tanktrunk/tanktrunk;
$CFG-dataroot  = $CFG-dirroot.'/moodledata';

require_once($CFG-dirroot/lib/setup.php);
  


Hi,

It reads as if $CFG is an object and -dirroot is not a public property 
of that object. So, I don't know what $CFG is, but I think the problem 
lays there.


Also, OOP is nice and all (not to start a thread about OOP again), but 
putting your config into an object seems a bit overdo to me.


--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] require_once dying silently

2008-04-09 Thread Zoltán Németh

Aschwin Wesselius írta:

Richard S. Crawford wrote:

Hi, everyone.

This one's been driving me bonkers for an hour now.  Anyone have any idea
why require_once would be dying silently in the script below?



$CFG-dirroot   = /home/rcrawford/public_html/tanktrunk/tanktrunk;
$CFG-dataroot  = $CFG-dirroot.'/moodledata';

require_once($CFG-dirroot/lib/setup.php);
  


Hi,

It reads as if $CFG is an object and -dirroot is not a public property 
of that object. So, I don't know what $CFG is, but I think the problem 
lays there.


if that property is not public but protected or private it would throw a 
fatal error.




Also, OOP is nice and all (not to start a thread about OOP again), but 
putting your config into an object seems a bit overdo to me.




I think you know I don't agree with that, but I too don't want to start 
this over ;)


greets,
Zoltán Németh

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



Re: [PHP] require_once dying silently

2008-04-09 Thread Greg Bowser
the above won't work, as the parser will try to interpret $CFG and
put it in the string first,

In that case, $CFG is either null, or it is indeed an object. If it is
a standard object, which I it appears to be, then a fatal error will
be thrown because there is no __tostring() function.  If it's null,
then require_once is referencing a directory beginning with '-',
again, there *should* be an error. Anyway..

I've seen $obj-property used many times in double quotes, and never
had a problem with that working. Personally though, I always use the
curly braces though because it highlights better in VIM :p

Also, OOP is nice and all (not to start a thread about OOP again),
but putting your config into an object seems a bit overdo to me.

Me too!! (not to continue the unstarted OOP discussion) It's a
practice I've seen used more than once.  I think people find that
syntax attractive.

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



Re: [PHP] require_once dying silently

2008-04-09 Thread Andrew Ballard
On Wed, Apr 9, 2008 at 2:40 AM, Zoltán Németh [EMAIL PROTECTED] wrote:
 Richard S. Crawford írta:

  Hi, everyone.
 
  This one's been driving me bonkers for an hour now.  Anyone have any idea
  why require_once would be dying silently in the script below?
 
  
 
  $CFG-dirroot   = /home/rcrawford/public_html/tanktrunk/tanktrunk;
  $CFG-dataroot  = $CFG-dirroot.'/moodledata';
 
  require_once($CFG-dirroot/lib/setup.php);
 

  the above won't work, as the parser will try to interpret $CFG and put it
 in the string first, then go ahead.
  try this:
  require_once($CFG-dirroot./lib/setup.php);
  or this:
  require_once({$CFG-dirroot}/lib/setup.php);

  greets,
  Zoltán Németh


  
 
  I've confirmed that the file setup.php exists and is readable.  I've got
  error_reporting in php.ini set to E_ALL.  I'm running Apache 2 and PHP5 on
  Kubuntu 7.10.  Nothing shows up in my apache error log, and PHP itself
  produces absolutely no output, even though it will produce output galore
  when I put in a deliberate syntax error.
 
  I've also tried:
 
  
  require_once($CFG-dirroot./lib/setup.php);
  
 
  but this didn't help.
 
  Any assistance at all would be greatly appreciated.
 
 

?php

header('Content-type: text/plain; charset=utf-8');
echo 'Zoltán, you forgot the PHP tags to get credit for your answer. :-)';
exit;

?

Andrew


Re: [PHP] require_once dying silently

2008-04-09 Thread Zoltán Németh

Greg Bowser írta:

the above won't work, as the parser will try to interpret $CFG and

put it in the string first,

In that case, $CFG is either null, or it is indeed an object. If it is
a standard object, which I it appears to be, then a fatal error will
be thrown because there is no __tostring() function.  If it's null,
then require_once is referencing a directory beginning with '-',
again, there *should* be an error. Anyway..

I've seen $obj-property used many times in double quotes, and never
had a problem with that working. Personally though, I always use the
curly braces though because it highlights better in VIM :p


I stand corrected, I just tried putting an object property into double 
quotes and it works


greets,
Zoltán Németh




Also, OOP is nice and all (not to start a thread about OOP again),

but putting your config into an object seems a bit overdo to me.

Me too!! (not to continue the unstarted OOP discussion) It's a
practice I've seen used more than once.  I think people find that
syntax attractive.




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



[PHP] require_once dying silently

2008-04-08 Thread Richard S. Crawford
Hi, everyone.

This one's been driving me bonkers for an hour now.  Anyone have any idea
why require_once would be dying silently in the script below?



$CFG-dirroot   = /home/rcrawford/public_html/tanktrunk/tanktrunk;
$CFG-dataroot  = $CFG-dirroot.'/moodledata';

require_once($CFG-dirroot/lib/setup.php);


I've confirmed that the file setup.php exists and is readable.  I've got
error_reporting in php.ini set to E_ALL.  I'm running Apache 2 and PHP5 on
Kubuntu 7.10.  Nothing shows up in my apache error log, and PHP itself
produces absolutely no output, even though it will produce output galore
when I put in a deliberate syntax error.

I've also tried:


require_once($CFG-dirroot./lib/setup.php);


but this didn't help.

Any assistance at all would be greatly appreciated.

-- 
Richard S. Crawford ([EMAIL PROTECTED])
http://www.mossroot.com
Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)


Re: [PHP] require_once dying silently

2008-04-08 Thread Chris

Richard S. Crawford wrote:

Hi, everyone.

This one's been driving me bonkers for an hour now.  Anyone have any idea
why require_once would be dying silently in the script below?



$CFG-dirroot   = /home/rcrawford/public_html/tanktrunk/tanktrunk;
$CFG-dataroot  = $CFG-dirroot.'/moodledata';

require_once($CFG-dirroot/lib/setup.php);


I've confirmed that the file setup.php exists and is readable.  I've got
error_reporting in php.ini set to E_ALL.  I'm running Apache 2 and PHP5 on
Kubuntu 7.10.  Nothing shows up in my apache error log, and PHP itself
produces absolutely no output, even though it will produce output galore
when I put in a deliberate syntax error.


Syntax errors in which file? The calling one (where you have the 
require_once) or the lib/setup.php file?


Maybe something in your code is disabling your error reporting, I'd put 
both:


error_reporting(E_ALL);
ini_set('display_errors', true);

in before the require_once and see what happens.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] require_once dying silently

2008-04-08 Thread Greg Bowser
?php echo 'begin brainstorm.'; ?

Is it possible that something is going wrong between the definition
of $CFG-foo and when you require that could cause $CFG-dirroot to be
null? Then it would point to /lib/setup.php, which definitely
shouldn't exist and should thus throw an error, but maybe it's worth
looking into.

?php require_once('Have you tried including a file that definitely
does not exist?'); ? That would rule out any error reporting problems
anyway.

Have you tried something to the effect of ?php echo __FILE__ . '
included'; ? on the first line of setup.php?  Adding ?php
print_r(get_included_files()); ? after the require_once() might also
help.

 I've confirmed that the file setup.php exists and is readable.
I apologize if this seems obvious, but for the sake of
brainstorming... it's readable by the user running apache, right? And
even if it weren't, that should have thrown an error *shrugs*

That's all I can think of. I hope it is of some use to you.

?php echo 'end brainstorm.'; ?

?php signature('GREG'); ?

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



Re: [PHP] require_once dying silently

2008-04-08 Thread Casey
On Tue, Apr 8, 2008 at 8:27 PM, Greg Bowser [EMAIL PROTECTED] wrote:
 ?php echo 'begin brainstorm.'; ?

  Is it possible that something is going wrong between the definition
  of $CFG-foo and when you require that could cause $CFG-dirroot to be
  null? Then it would point to /lib/setup.php, which definitely
  shouldn't exist and should thus throw an error, but maybe it's worth
  looking into.

  ?php require_once('Have you tried including a file that definitely
  does not exist?'); ? That would rule out any error reporting problems
  anyway.

  Have you tried something to the effect of ?php echo __FILE__ . '
  included'; ? on the first line of setup.php?  Adding ?php
  print_r(get_included_files()); ? after the require_once() might also
  help.


   I've confirmed that the file setup.php exists and is readable.
  I apologize if this seems obvious, but for the sake of
  brainstorming... it's readable by the user running apache, right? And
  even if it weren't, that should have thrown an error *shrugs*

  That's all I can think of. I hope it is of some use to you.

  ?php echo 'end brainstorm.'; ?

  ?php signature('GREG'); ?



You should try:
?php
require_once(/home/rcrawford/public_html/tanktrunk/tanktrunk/lib/setup.php);
?

-- 
-Casey

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



Re: [PHP] require_once and E_WARNING?

2006-07-06 Thread Martin Marques

On Wed, 5 Jul 2006, [EMAIL PROTECTED] wrote:


Hello all,

According to the PHP Manual, when require or require_once failes, an
E_ERROR is triggered: require() and include()  are identical in every way
except how they handle failure. include() produces a Warning while
require() results in a  Fatal Error. (With 'Fatal Error' being a link to
E_ERROR).

Thing is, when using a custom error handler via set_error_handler(), it
appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4
under Linux.

There are one of three possibilities: I am suffering from a lapse in
lucidity (common), the manual is wrong (possible), or PHP is broken
somehow (unlikely). I'm guessing it's the first, but what am I doing
wrong? I'd like to get a second opinion before submitting a bug. I
searched bugs.php.net but was unable to find anything relevant for 5.1.4.

Code:
function default_error_handler($code, $error, $file, $line) {
  switch ($code) {
  case E_ERROR:
 die (Error: $error);
  case E_WARNING:
 die(Warning: $error);
  default:
 die(Something else entirely: $error);
  }
}


What happens if you put breaks after the die()? This shouldn't be 
necesary, but it wouldn't hurt to try. ;-)


As I see in the example of the PHP manual, a break is put even after an 
exit(1) call.



set_error_handler('default_error_handler');
require('This file does not exist. At least not here!');


Have you tried this handler with something more fatal, like a missing 
semi-colon or a } missmatch?


--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
-
Lic. Martín Marqués |   SELECT 'mmarques' ||
Centro de Telemática|   '@' || 'unl.edu.ar';
Universidad Nacional|   DBA, Programador,
del Litoral |   Administrador
-
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] require_once and E_WARNING?

2006-07-06 Thread chris smith

On 7/6/06, Martin Marques martin@bugs.unl.edu.ar wrote:

On Wed, 5 Jul 2006, [EMAIL PROTECTED] wrote:

 Hello all,

 According to the PHP Manual, when require or require_once failes, an
 E_ERROR is triggered: require() and include()  are identical in every way
 except how they handle failure. include() produces a Warning while
 require() results in a  Fatal Error. (With 'Fatal Error' being a link to
 E_ERROR).

 Thing is, when using a custom error handler via set_error_handler(), it
 appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4
 under Linux.

 There are one of three possibilities: I am suffering from a lapse in
 lucidity (common), the manual is wrong (possible), or PHP is broken
 somehow (unlikely). I'm guessing it's the first, but what am I doing
 wrong? I'd like to get a second opinion before submitting a bug. I
 searched bugs.php.net but was unable to find anything relevant for 5.1.4.

 Code:
 function default_error_handler($code, $error, $file, $line) {
   switch ($code) {
   case E_ERROR:
  die (Error: $error);
   case E_WARNING:
  die(Warning: $error);
   default:
  die(Something else entirely: $error);
   }
 }

What happens if you put breaks after the die()? This shouldn't be
necesary, but it wouldn't hurt to try. ;-)

As I see in the example of the PHP manual, a break is put even after an
exit(1) call.

 set_error_handler('default_error_handler');
 require('This file does not exist. At least not here!');

Have you tried this handler with something more fatal, like a missing
semi-colon or a } missmatch?


That will cause a parse error and the script won't even run.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] require_once and E_WARNING?

2006-07-06 Thread Jochem Maas
chris smith wrote:
 On 7/6/06, Martin Marques martin@bugs.unl.edu.ar wrote:
 On Wed, 5 Jul 2006, [EMAIL PROTECTED] wrote:

  Hello all,
 
  According to the PHP Manual, when require or require_once failes, an
  E_ERROR is triggered: require() and include()  are identical in
 every way
  except how they handle failure. include() produces a Warning while
  require() results in a  Fatal Error. (With 'Fatal Error' being a
 link to
  E_ERROR).
 
  Thing is, when using a custom error handler via set_error_handler(), it
  appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4
  under Linux.
 
  There are one of three possibilities: I am suffering from a lapse in
  lucidity (common), the manual is wrong (possible), or PHP is broken
  somehow (unlikely). I'm guessing it's the first, but what am I doing
  wrong? I'd like to get a second opinion before submitting a bug. I
  searched bugs.php.net but was unable to find anything relevant for
 5.1.4.
 
  Code:
  function default_error_handler($code, $error, $file, $line) {
switch ($code) {
case E_ERROR:
   die (Error: $error);
case E_WARNING:
   die(Warning: $error);
default:
   die(Something else entirely: $error);
}
  }

 What happens if you put breaks after the die()? This shouldn't be
 necesary, but it wouldn't hurt to try. ;-)

 As I see in the example of the PHP manual, a break is put even after an
 exit(1) call.

  set_error_handler('default_error_handler');
  require('This file does not exist. At least not here!');

 Have you tried this handler with something more fatal, like a missing
 semi-colon or a } missmatch?
 
 That will cause a parse error and the script won't even run.

try it with a call to an undefined function e.g.:

$foo = thisFunctionDoesNotExistAtLeastItHadBetterNot();

 

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



Re: [PHP] require_once and E_WARNING?

2006-07-06 Thread Martin Marques

On Thu, 6 Jul 2006, chris smith wrote:



Have you tried this handler with something more fatal, like a missing
semi-colon or a } missmatch?


That will cause a parse error and the script won't even run.


You're right. My wrong. :-(

--
 21:50:04 up 2 days,  9:07,  0 users,  load average: 0.92, 0.37, 0.18
-
Lic. Martín Marqués |   SELECT 'mmarques' ||
Centro de Telemática|   '@' || 'unl.edu.ar';
Universidad Nacional|   DBA, Programador,
del Litoral |   Administrador
-
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] require_once and E_WARNING?

2006-07-06 Thread KermodeBear

chris smith wrote:
 try it with a call to an undefined function e.g.:
 $foo = thisFunctionDoesNotExistAtLeastItHadBetterNot();

When this is done, the error handler doesn't get called at all, and the
script simply dies with an error message (which could be a bug as well, but
might also be considered a 'parse error' even if it happens at runtime; I
doubt they would fix it).

I read through the set_error_handler() documentation again though, and I
found that:  The following error types cannot be handled with a user
defined function: E_ERROR[...]

So, I'm guessing that the require() functions raise an E_WARNING before the
E_ERROR. Seems odd. Perhaps what happens under the hood is that require()
calls include(), which would raise an E_WARNING when it fails, then the
require() code checks the result of include() and if it failed then it
raises the E_ERROR.

It pays to RTFM more closely, it seems. (o;  My bad.


-- 
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] require_once and E_WARNING?

2006-07-05 Thread php
Hello all,

According to the PHP Manual, when require or require_once failes, an
E_ERROR is triggered: require() and include()  are identical in every way
except how they handle failure. include() produces a Warning while
require() results in a  Fatal Error. (With 'Fatal Error' being a link to
E_ERROR).

Thing is, when using a custom error handler via set_error_handler(), it
appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4
under Linux.

There are one of three possibilities: I am suffering from a lapse in
lucidity (common), the manual is wrong (possible), or PHP is broken
somehow (unlikely). I'm guessing it's the first, but what am I doing
wrong? I'd like to get a second opinion before submitting a bug. I
searched bugs.php.net but was unable to find anything relevant for 5.1.4.

Code:
function default_error_handler($code, $error, $file, $line) {
   switch ($code) {
   case E_ERROR:
  die (Error: $error);
   case E_WARNING:
  die(Warning: $error);
   default:
  die(Something else entirely: $error);
   }
}
set_error_handler('default_error_handler');
require('This file does not exist. At least not here!');

Result:
Warning: require(This file does not exist. At least not here!)
[function.require]: failed to open stream: No such file or directory

Expected Result:
Error: require(This file does not exist. At least not here!)
[function.require]: failed to open stream: No such file or directory

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



Re: [PHP] require_once and E_WARNING?

2006-07-05 Thread Chris

[EMAIL PROTECTED] wrote:

Hello all,

According to the PHP Manual, when require or require_once failes, an
E_ERROR is triggered: require() and include()  are identical in every way
except how they handle failure. include() produces a Warning while
require() results in a  Fatal Error. (With 'Fatal Error' being a link to
E_ERROR).

Thing is, when using a custom error handler via set_error_handler(), it
appears to be triggering an E_WARNING, not an E_ERROR. Using PHP 5.1.4
under Linux.

There are one of three possibilities: I am suffering from a lapse in
lucidity (common), the manual is wrong (possible), or PHP is broken
somehow (unlikely). I'm guessing it's the first, but what am I doing
wrong? I'd like to get a second opinion before submitting a bug. I
searched bugs.php.net but was unable to find anything relevant for 5.1.4.

Code:
function default_error_handler($code, $error, $file, $line) {
   switch ($code) {
   case E_ERROR:
  die (Error: $error);
   case E_WARNING:
  die(Warning: $error);
   default:
  die(Something else entirely: $error);
   }
}
set_error_handler('default_error_handler');
require('This file does not exist. At least not here!');

Result:
Warning: require(This file does not exist. At least not here!)
[function.require]: failed to open stream: No such file or directory

Expected Result:
Error: require(This file does not exist. At least not here!)
[function.require]: failed to open stream: No such file or directory



If you comment out the 'set_error_handler' line what happens? Do you get 
what you expect (and what should happen) ?


It looks like a pretty simple bug report to me but others may have 
reasons why it's not working.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] require_once and E_WARNING?

2006-07-05 Thread php
 Code:
 function default_error_handler($code, $error, $file, $line) {
switch ($code) {
case E_ERROR:
   die (Error: $error);
case E_WARNING:
   die(Warning: $error);
default:
   die(Something else entirely: $error);
}
 }
 set_error_handler('default_error_handler');
 require('This file does not exist. At least not here!');

 Result:
 Warning: require(This file does not exist. At least not here!)
 [function.require]: failed to open stream: No such file or directory

 Expected Result:
 Error: require(This file does not exist. At least not here!)
 [function.require]: failed to open stream: No such file or directory


 If you comment out the 'set_error_handler' line what happens? Do you get
 what you expect (and what should happen) ?

 It looks like a pretty simple bug report to me but others may have
 reasons why it's not working.

Without the error handler, I get the expected result: A fatal error with
the script dying. That is what makes this so mysterious. Doesn't make
sense that it would raise a different kind of error under different
circumstances. It should have the same value every time.

I'm going to sit on this for a day or so and see what people say before I
toss it over to the bug folks. No sense in bothering them if I'm being a
bonehead. (o;

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



[PHP] require_once hell

2006-03-29 Thread Adrian Bruce

Hi

this may be a stupid moment but i cant find an help on google so.i 
am including two classes in my code using the  require_once(path to 
file) method.  this works fine for the first class but when including 
the second it simply outputs the contents on to the page.  I feel I must 
be missing something stupid so i have not included any example code, any 
general ideas?


Thanks in advance

Ade

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



Re: [PHP] require_once hell

2006-03-29 Thread Thomas Munz
Forgot the ?php tag in the second class?


on Wednesday 29 March 2006 12:48, Adrian Bruce wrote:
 Hi

 this may be a stupid moment but i cant find an help on google so.i
 am including two classes in my code using the  require_once(path to
 file) method.  this works fine for the first class but when including
 the second it simply outputs the contents on to the page.  I feel I must
 be missing something stupid so i have not included any example code, any
 general ideas?

 Thanks in advance

 Ade

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



Re: [PHP] require_once hell

2006-03-29 Thread gustav
 Hi

 this may be a stupid moment but i cant find an help on google so.i
 am including two classes in my code using the  require_once(path to
 file) method.  this works fine for the first class but when including
 the second it simply outputs the contents on to the page.  I feel I must
 be missing something stupid so i have not included any example code, any
 general ideas?

 Thanks in advance

 Ade

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


Hi!

It would be easier if you would include some code...

/Gustav Wiberg

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



[PHP] Require_once(_)...when does it reset?

2004-10-28 Thread Mike


I am playing with PEAR_Info on my server. It was working fine, then I
upgraded some classes, now it is not.

I think it is because PHP is holding on to the old code from some
require_once functions.

I may be totally wrong but that is all I can think of what would cause this.

Other classes (that I did not execute before updating) work fine.

Is there a way to reset PHP if this is the case?

Thanks.



++
Mike Yrabedra 
[EMAIL PROTECTED] 
Your Mac Intelligence Resource
++
W: http://www.macagent.com/
E: [EMAIL PROTECTED]

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



[PHP] Require_once return value on error?

2004-04-30 Thread Vincent DUPONT
Hello,

I need to load various php files programatically and I use require_once($file_path) 
for this purpose.
My question is : is there a way to know if the file was found or not? if the file 
generated an error or not?

thank you
vincent

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



Re: [PHP] Require_once return value on error?

2004-04-30 Thread Stuart
Vincent DUPONT wrote:
I need to load various php files programatically and I use require_once($file_path) 
for this purpose.
My question is : is there a way to know if the file was found or not? if the file 
generated an error or not?
RTFM: http://php.net/include

require() and include() are identical in every way except how they 
handle failure. include() produces a Warning while require() results in 
a  Fatal Error.

require_once and include_once behave in the same way.

You can check the return value from include() to see if it was 
successful. If the included file ends with a return statement then you 
will get that if it succeeds. If not you'll get the value 1 if it succeeds.

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


[PHP] require_once('') relative path problem

2004-04-22 Thread Sheeraz fazal
Hi,
I have problem in undertanding the require_once/require/include/include_once
functionality. Php files in my project are located in different folders.
Some folders have common files for other files. And file layout is like this

/*
File: a.php
*/
require_once('../test/db.php');
...


/*
File: db.php
*/
require_once('../globals/global.php');
...


when i include a.php in another file i get error for global.php file that
path could not be found. And if i correct the path in db.php then someother
file which is using db.php will get error. So, can someone elaborate that
how relative path works in require_once. what is the starting directory for
require_once function which is using relative path.

Or

Is there any way that i can included some constant which include the
absolute path from which all relative paths can be determined?

Comments welcome.

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



RE: [PHP] require_once('') relative path problem

2004-04-22 Thread Tyler Replogle
hey,
i didn't quite get when you ment by that but have you tried using 
$DOCUMENT_ROOT before your path, that might help it will be something like 
this
require_once('$DOCUMENT_ROOT/test/db.php');
$DOCUMENT_ROOT  goes to your first folder that shows up online (where your 
index page is)


From: Sheeraz fazal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP] require_once('') relative path problem
Date: Thu, 22 Apr 2004 14:34:23 -0600
Hi,
I have problem in undertanding the 
require_once/require/include/include_once
functionality. Php files in my project are located in different folders.
Some folders have common files for other files. And file layout is like 
this

/*
File: a.php
*/
require_once('../test/db.php');
...
/*
File: db.php
*/
require_once('../globals/global.php');
...
when i include a.php in another file i get error for global.php file that
path could not be found. And if i correct the path in db.php then someother
file which is using db.php will get error. So, can someone elaborate that
how relative path works in require_once. what is the starting directory for
require_once function which is using relative path.
Or

Is there any way that i can included some constant which include the
absolute path from which all relative paths can be determined?
Comments welcome.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_
Lose those love handles! MSN Fitness shows you two moves to slim your waist. 
http://fitness.msn.com/articles/feeds/article.aspx?dept=exercisearticle=et_pv_030104_lovehandles

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


Re: [PHP] require_once('') relative path problem

2004-04-22 Thread Curt Zirzow
* Thus wrote Sheeraz fazal ([EMAIL PROTECTED]):
 Hi,
 I have problem in undertanding the require_once/require/include/include_once
 functionality. Php files in my project are located in different folders.
 Some folders have common files for other files. And file layout is like this

Include files relative to your include_path

Web Directory:
/home/user/public_html/

Include Directories:
/home/user/phpinclude/test/
/home/user/phpinclude/globals/


php.ini (or similar):
include_path = /home/user/phpinclude:/usr/local/lib/php

public_html/page.php:
?php
require_once('test/db.php');
?

db.php:
?php
require_once('globals/global.php');
?

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] require_once('') relative path problem

2004-04-22 Thread Richard Harb
did you check the online manual for those funcitons yet?

I have found the user notes to be a wealthy ressource on that matter.

This topic also came up very recently on this list so checking the
archives might solve it.

Richard


Thursday, April 22, 2004, 10:34:23 PM, thus was written:
 Hi,
 I have problem in undertanding the
 require_once/require/include/include_once
 functionality. Php files in my project are located in different folders.
 Some folders have common files for other files. And file layout is like this

 /*
 File: a.php
 */
 require_once('../test/db.php');
 ...


 /*
 File: db.php
 */
 require_once('../globals/global.php');
 ...


 when i include a.php in another file i get error for global.php file that
 path could not be found. And if i correct the path in db.php then someother
 file which is using db.php will get error. So, can someone elaborate that
 how relative path works in require_once. what is the starting directory for
 require_once function which is using relative path.

 Or

 Is there any way that i can included some constant which include the
 absolute path from which all relative paths can be determined?

 Comments welcome.

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



Re: [PHP] require_once('') relative path problem

2004-04-22 Thread Jordi Canals
Curt Zirzow wrote:

* Thus wrote Sheeraz fazal ([EMAIL PROTECTED]):

Hi,
I have problem in undertanding the require_once/require/include/include_once
functionality. Php files in my project are located in different folders.
Some folders have common files for other files. And file layout is like this


Include files relative to your include_path

php.ini (or similar):
include_path = /home/user/phpinclude:/usr/local/lib/php
if you do not have access to your PHP.INI ... take a look at the 
functions set_icnlude_path() and get_include_path()

If all your included files are in the same directory, you can write on 
them something like (I don't have my code at hand now):

set_include_path(get_include_path() .':'. dirname(__FILE__));

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


Re: [PHP] require_once('') relative path problem

2004-04-22 Thread Nikolay Bachiyski
Hello,

Just imagine you had just copied the file you want to include and then
pasted it into the master file.
PHP does not any path translation. For example if you have the following
structure:
- /
-- a.php
-- b.php
-- /utils
 c.php
 d.php

Let c.php is included in a.php.
Then if you want to include d.php in c.php you should use include
utils/d.php. Obviously if you want to include b.php inside c.php just
include b.php is pretty enough.

I have many times thought that the inclusion mechanism could sometimes be
not only confusing, but also unhandy for use in larger libraries. In order
to be your package easy deployable usually you go through inventing your own
constant-based path translation system.
Unfortunately my reflections on the subject of the inclusion system
improvements have never been much fruitful

Regards,
Nikolay

On Friday, April 23, 2004 2:27 AM Richard Harb [EMAIL PROTECTED] wrote:


 did you check the online manual for those funcitons yet?

 I have found the user notes to be a wealthy ressource on that matter.

 This topic also came up very recently on this list so checking the
 archives might solve it.

 Richard


 Thursday, April 22, 2004, 10:34:23 PM, thus was written:
  Hi,
  I have problem in undertanding the
  require_once/require/include/include_once
  functionality. Php files in my project are located in different folders.
  Some folders have common files for other files. And file layout is like
this

  /*
  File: a.php
  */
  require_once('../test/db.php');
  ...


  /*
  File: db.php
  */
  require_once('../globals/global.php');
  ...


  when i include a.php in another file i get error for global.php file
that
  path could not be found. And if i correct the path in db.php then
someother
  file which is using db.php will get error. So, can someone elaborate
that
  how relative path works in require_once. what is the starting directory
for
  require_once function which is using relative path.

  Or

  Is there any way that i can included some constant which include the
  absolute path from which all relative paths can be determined?

  Comments welcome.

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




Re: [PHP] require_once('') relative path problem

2004-04-22 Thread Torsten Roehr
Tyler Replogle [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 hey,
 i didn't quite get when you ment by that but have you tried using
 $DOCUMENT_ROOT before your path, that might help it will be something like
 this
 require_once('$DOCUMENT_ROOT/test/db.php');
 $DOCUMENT_ROOT  goes to your first folder that shows up online (where your
 index page is)

Use the Server array variable instead (the brackets can be omitted):

require_once $_SERVER['DOCUMENT_ROOT'] . '/test/db.php';

Regards,
Torsten



 From: Sheeraz fazal [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: [PHP] require_once('') relative path problem
 Date: Thu, 22 Apr 2004 14:34:23 -0600
 
 Hi,
 I have problem in undertanding the
 require_once/require/include/include_once
 functionality. Php files in my project are located in different folders.
 Some folders have common files for other files. And file layout is like
 this
 
 /*
  File: a.php
 */
 require_once('../test/db.php');
 ...
 
 
 /*
 File: db.php
 */
 require_once('../globals/global.php');
 ...
 
 
 when i include a.php in another file i get error for global.php file that
 path could not be found. And if i correct the path in db.php then
someother
 file which is using db.php will get error. So, can someone elaborate that
 how relative path works in require_once. what is the starting directory
for
 require_once function which is using relative path.
 
 Or
 
 Is there any way that i can included some constant which include the
 absolute path from which all relative paths can be determined?
 
 Comments welcome.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

 _
 Lose those love handles! MSN Fitness shows you two moves to slim your
waist.

http://fitness.msn.com/articles/feeds/article.aspx?dept=exercisearticle=et_
pv_030104_lovehandles

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



[PHP] require_once '../config.php'; doesn't work?

2004-04-09 Thread Mike Zornek
Is it true I can't include a file up a dir like this:

require_once '../config.php';

This seems to work though:

require_once 'settings/db.php';

Strange.

~ Mike
-
Mike Zornek
Web Designer, Media Developer, Programmer and Geek
Personal site: http://MikeZornek.com
New Project: http://WebDevWiki.com

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



Re: [PHP] require_once '../config.php'; doesn't work?

2004-04-09 Thread Jason Giangrande
Mike Zornek wrote:
Is it true I can't include a file up a dir like this:

require_once '../config.php';
You should be able to include a file up one (or more) directories.  Are 
you sure it's only up one directory from were your script is being 
called from?

This seems to work though:

require_once 'settings/db.php';

Strange.
--
Jason Giangrande [EMAIL PROTECTED]
http://www.giangrande.org
http://www.dogsiview.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] require_once '../config.php'; doesn't work?

2004-04-09 Thread Richard Harb
Depends on where the executed script is located ...
And it always depends on the script that is called - if you give a
relative path like you did here.

if the script you called would be
http://www.example.com/news/2004-04-10/mypage.php

then config.php would have to be in /news

if your layout is like:
/   (root)
|-settings/
|-news/
  |-2004-04-10/

and you call a script in root then db.php would be included, but not
if called from the dir news ...

You could either prepend something (like $_SERVER['DOCUMENT_ROOT']) or
you define something like
define ('MY_SETTINGS_DIR', '/usr/local/www/settings');
so the path will be absolute ...

or you could write some function that calculates the relative path to
root no matter where the script you called resides in - and prepend
that string then ...

or 

hth

Richard


Saturday, April 10, 2004, 4:36:31 AM, you wrote:

 Is it true I can't include a file up a dir like this:

 require_once '../config.php';

 This seems to work though:

 require_once 'settings/db.php';

 Strange.

 ~ Mike
 -
 Mike Zornek
 Web Designer, Media Developer, Programmer and Geek
 Personal site: http://MikeZornek.com
 New Project: http://WebDevWiki.com




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



Re: [PHP] require_once '../config.php'; doesn't work?

2004-04-09 Thread Marek Kilimajer
Mike Zornek wrote:
Is it true I can't include a file up a dir like this:

require_once '../config.php';

This seems to work though:

require_once 'settings/db.php';

Strange.

Both works as long as other settings permit it - file permission and 
owner, safe mode restrictions

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


RE: [PHP] require_once for php3

2003-03-24 Thread Don Read

On 24-Mar-2003 daniel wrote:
 hi there is a way to include files once in php3 ?
 

I've always used function_exists():

if (! function_exists('debug'))
include('common.inc');// get the basics

if (! function_exists('array_pop'))
include('libphp4.php3');  // get emulation lib.

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



Re: [PHP] require_once for php3

2003-03-23 Thread Jason Sheets
You could write a wrapper around the include function that uses a global 
array, each time it is called it checks the global array to see if the 
file has been included, if it hasn't it includes the file and adds the 
file to the array.

Jason
daniel wrote:
hi there is a way to include files once in php3 ?





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


Re: [PHP] require_once adds a 1

2003-03-08 Thread James
?
if ([EMAIL PROTECTED](topten.php)){
echo Loading of top ten failed on line .__LINE__;
}
?


Gary [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thanks for your response James!
 but still I must be doing something wrong the 1 is a persistent little
 bugger. Have you any tips on how to rewrite:

 ?php
 echo @ require_once(topten.php);
  ?
 using the ob_methods?
 Again thanx for your response
 Gary

 James Holden wrote:
  The '1' is received simply because your requirement clause echoed the
  result to the page.
 
  include, require and include_once all return boolean results of 1 or 0
  which indicates a successful loading of said include.   If you want to
  suppress the output of an include use ob_ methods which prevent output
  the stdout.
 
  Simply putting 'include_once(anyfile.php)' will output whatever
  processes occur within that include.
  Putting the echo statement will additionally output the status of the
  include operation.
 
  Regards,
  Jim
  londontown.com
 
 
  Ernest E Vogelsinger wrote:
 
  At 17:28 07.03.2003, Gary spoke out and said:
  [snip]
 
 
  Hi
  I've included the following in a php document:
  ?php
  echo @ require_once(anyfile.php)
 
 
  and it works exactly as I expect except at the end of the included
  document theres a single 1 displayed. I've noticed also that if I
  include a document in the included document the end result will be
  the document I want exactly as I want it with the addition of two
  ones 11s can anyone tell me how to get rid of the ones?
  (if I run anyfile.php by itself there are no 1s)
 
 
  [snip]
 
  This happens if the included file returns some value, in your case
  it seems to return true. Remove the return something statement
  (you may simply return; if necessary) and the 1 will be history.





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



[PHP] require_once adds a 1

2003-03-07 Thread Gary
Hi
I've included the following in a php document:
?php
echo @ require_once(anyfile.php)

and it works exactly as I expect except at the end of the included document
theres a single 1 displayed. I've noticed also that if I include a
document in the included document the end result will be the document I want
exactly as I want it with the addition of two ones 11s can anyone tell me
how to get rid of the ones?
(if I run anyfile.php by itself there are no 1s)
Gary



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



Re: [PHP] require_once adds a 1

2003-03-07 Thread Mincu Alexandru
On Fri, 2003-03-07 at 18:28, Gary wrote:
 Hi
 I've included the following in a php document:
 ?php
 echo @ require_once(anyfile.php)
 
use only 
?php
require_once anyfile.php;
?
if you use echo require_once(somefile.php); it will include the file
and then echo 1 witch is the return value of require_once;

 and it works exactly as I expect except at the end of the included document
 theres a single 1 displayed. I've noticed also that if I include a
 document in the included document the end result will be the document I want
 exactly as I want it with the addition of two ones 11s can anyone tell me
 how to get rid of the ones?
 (if I run anyfile.php by itself there are no 1s)
 Gary


Mincu Alexandru 
 intelinet.ro 
Tel:
+4 0745 369 719 
+4 021 314 00 21 
www.intelinet.ro
[EMAIL PROTECTED]


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



Re: [PHP] require_once adds a 1

2003-03-07 Thread Ernest E Vogelsinger
At 17:28 07.03.2003, Gary spoke out and said:
[snip]
Hi
I've included the following in a php document:
?php
echo @ require_once(anyfile.php)

and it works exactly as I expect except at the end of the included document
theres a single 1 displayed. I've noticed also that if I include a
document in the included document the end result will be the document I want
exactly as I want it with the addition of two ones 11s can anyone tell me
how to get rid of the ones?
(if I run anyfile.php by itself there are no 1s)
[snip] 

This happens if the included file returns some value, in your case it seems
to return true. Remove the return something statement (you may simply
return; if necessary) and the 1 will be history.


-- 
   O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/


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



Re: [PHP] require_once adds a 1

2003-03-07 Thread James Holden
The '1' is received simply because your requirement clause echoed the 
result to the page.

include, require and include_once all return boolean results of 1 or 0 
which indicates a successful loading of said include.   If you want to 
suppress the output of an include use ob_ methods which prevent output 
the stdout.

Simply putting 'include_once(anyfile.php)' will output whatever 
processes occur within that include.  
Putting the echo statement will additionally output the status of the 
include operation.

Regards,
Jim
londontown.com
Ernest E Vogelsinger wrote:

At 17:28 07.03.2003, Gary spoke out and said:
[snip]
 

Hi
I've included the following in a php document:
?php
echo @ require_once(anyfile.php)
   

and it works exactly as I expect except at the end of the included document
theres a single 1 displayed. I've noticed also that if I include a
document in the included document the end result will be the document I want
exactly as I want it with the addition of two ones 11s can anyone tell me
how to get rid of the ones?
(if I run anyfile.php by itself there are no 1s)
   

[snip] 

This happens if the included file returns some value, in your case it seems
to return true. Remove the return something statement (you may simply
return; if necessary) and the 1 will be history.
 




Re: [PHP] require_once adds a 1

2003-03-07 Thread Gary
Thanks for your response James!
but still I must be doing something wrong the 1 is a persistent little
bugger. Have you any tips on how to rewrite:

?php
echo @ require_once(topten.php);
 ?
using the ob_methods?
Again thanx for your response
Gary

James Holden wrote:
 The '1' is received simply because your requirement clause echoed the
 result to the page.

 include, require and include_once all return boolean results of 1 or 0
 which indicates a successful loading of said include.   If you want to
 suppress the output of an include use ob_ methods which prevent output
 the stdout.

 Simply putting 'include_once(anyfile.php)' will output whatever
 processes occur within that include.
 Putting the echo statement will additionally output the status of the
 include operation.

 Regards,
 Jim
 londontown.com


 Ernest E Vogelsinger wrote:

 At 17:28 07.03.2003, Gary spoke out and said:
 [snip]


 Hi
 I've included the following in a php document:
 ?php
 echo @ require_once(anyfile.php)


 and it works exactly as I expect except at the end of the included
 document theres a single 1 displayed. I've noticed also that if I
 include a document in the included document the end result will be
 the document I want exactly as I want it with the addition of two
 ones 11s can anyone tell me how to get rid of the ones?
 (if I run anyfile.php by itself there are no 1s)


 [snip]

 This happens if the included file returns some value, in your case
 it seems to return true. Remove the return something statement
 (you may simply return; if necessary) and the 1 will be history.



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



Re: [PHP] require_once adds a 1

2003-03-07 Thread Ernest E Vogelsinger
At 20:19 07.03.2003, Gary said:
[snip]
Thanks for your response James!
but still I must be doing something wrong the 1 is a persistent little
bugger. Have you any tips on how to rewrite:

?php
echo @ require_once(topten.php);
 ?
using the ob_methods?
[snip] 

Rewrite this to just
require_once('topten.php');
No need to echo here.

Using output buffering the 1 would still appear, some microseconds later...


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] require_once adds a 1

2003-03-07 Thread Gary
Ernest E Vogelsinger wrote:
 At 20:19 07.03.2003, Gary said:

 Rewrite this to just
 require_once('topten.php');

Thanx Ernest!
that does the trick
Gary



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



[PHP] REQUIRE_ONCE AND CLASSES

2002-12-16 Thread Mauro Romano Trajber
Hi all.
I got a problem.
When i include a external file using require_once('my_file.php'); in a class file i 
cant use my_file´s vars and functions.
Example:
?
require_once HTML/IT.php;
class Home{
  var $tpl_home= new IntegratedTemplate(../templates);
   function Home(){
 $this-tpl_home-loadTemplatefile(index.tpl.html, true, true);
 $this-tpl_home-setCurrentBlock(GEREN);
 $this-tpl_home-setVariable(GEREN,b);
 $this-tpl_home-parseCurrentBlock(GEREN);
 $this-tpl_home-setCurrentBlock(PRINCIPAL);
 $this-tpl_home-setVariable(DADOS,a);
 $this-tpl_home-parseCurrentBlock(PRINCIPAL);
   }
   function show(){
   $this-tpl_home-show();
   }
}
$alo=new Home();
$alo-show();
?

DONT WORK!!!
why?
im new in php.
i will thank any help.
sorry my english!!! :)
Mauro!


Re: [PHP] REQUIRE_ONCE AND CLASSES

2002-12-16 Thread Wico de Leeuw
Hiya

Try it like this:

?
require_once HTML/IT.php;
class Home {
var $tpl_home = NULL;

function Home () {
$this-tpl_home = new 
IntegratedTemplate(../templates);
}

function Home(){
$this-tpl_home-loadTemplatefile(index.tpl.html, 
true, true);
$this-tpl_home-setCurrentBlock(GEREN);
$this-tpl_home-setVariable(GEREN,b);
$this-tpl_home-parseCurrentBlock(GEREN);
$this-tpl_home-setCurrentBlock(PRINCIPAL);
$this-tpl_home-setVariable(DADOS,a);
$this-tpl_home-parseCurrentBlock(PRINCIPAL);
}

function show(){
$this-tpl_home-show();
}
}
$alo=new Home();
$alo-show();
?

P.S. you can assign 'dynamic' content to a class var in a (class) function, 
not with var $var = aFunction() or something

At 16:24 16-12-02 +, Mauro Romano Trajber wrote:
Hi all.
I got a problem.
When i include a external file using require_once('my_file.php'); in a 
class file i cant use my_file´s vars and functions.
Example:
?
require_once HTML/IT.php;
class Home{
  var $tpl_home= new IntegratedTemplate(../templates);
   function Home(){
 $this-tpl_home-loadTemplatefile(index.tpl.html, true, true);
 $this-tpl_home-setCurrentBlock(GEREN);
 $this-tpl_home-setVariable(GEREN,b);
 $this-tpl_home-parseCurrentBlock(GEREN);
 $this-tpl_home-setCurrentBlock(PRINCIPAL);
 $this-tpl_home-setVariable(DADOS,a);
 $this-tpl_home-parseCurrentBlock(PRINCIPAL);
   }
   function show(){
   $this-tpl_home-show();
   }
}
$alo=new Home();
$alo-show();
?

DONT WORK!!!
why?
im new in php.
i will thank any help.
sorry my english!!! :)
Mauro!


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




Re: [PHP] REQUIRE_ONCE AND CLASSES

2002-12-16 Thread Wico de Leeuw
Ofcourse there can only be one home function:

?
require_once HTML/IT.php;

class Home {
var $tpl_home = NULL;

function Home(){
$this-tpl_home = new 
IntegratedTemplate(../templates);
$this-tpl_home-loadTemplatefile(index.tpl.html, 
true, true);
$this-tpl_home-setCurrentBlock(GEREN);
$this-tpl_home-setVariable(GEREN,b);
$this-tpl_home-parseCurrentBlock(GEREN);
$this-tpl_home-setCurrentBlock(PRINCIPAL);
$this-tpl_home-setVariable(DADOS,a);
$this-tpl_home-parseCurrentBlock(PRINCIPAL);
}

function show(){
$this-tpl_home-show();
}
}
$alo=new Home();
$alo-show();
?


At 17:36 16-12-02 +0100, Wico de Leeuw wrote:
Hiya

Try it like this:

?
require_once HTML/IT.php;
class Home {
var $tpl_home = NULL;

function Home () {
$this-tpl_home = new IntegratedTemplate(../templates);
}

function Home(){

$this-tpl_home-loadTemplatefile(index.tpl.html, true, true);
$this-tpl_home-setCurrentBlock(GEREN);
$this-tpl_home-setVariable(GEREN,b);
$this-tpl_home-parseCurrentBlock(GEREN);
$this-tpl_home-setCurrentBlock(PRINCIPAL);
$this-tpl_home-setVariable(DADOS,a);
$this-tpl_home-parseCurrentBlock(PRINCIPAL);
}

function show(){
$this-tpl_home-show();
}
}
$alo=new Home();
$alo-show();
?

P.S. you can assign 'dynamic' content to a class var in a (class) 
function, not with var $var = aFunction() or something

At 16:24 16-12-02 +, Mauro Romano Trajber wrote:
Hi all.
I got a problem.
When i include a external file using require_once('my_file.php'); in a 
class file i cant use my_file´s vars and functions.
Example:
?
require_once HTML/IT.php;
class Home{
  var $tpl_home= new IntegratedTemplate(../templates);
   function Home(){
 $this-tpl_home-loadTemplatefile(index.tpl.html, true, true);
 $this-tpl_home-setCurrentBlock(GEREN);
 $this-tpl_home-setVariable(GEREN,b);
 $this-tpl_home-parseCurrentBlock(GEREN);
 $this-tpl_home-setCurrentBlock(PRINCIPAL);
 $this-tpl_home-setVariable(DADOS,a);
 $this-tpl_home-parseCurrentBlock(PRINCIPAL);
   }
   function show(){
   $this-tpl_home-show();
   }
}
$alo=new Home();
$alo-show();
?

DONT WORK!!!
why?
im new in php.
i will thank any help.
sorry my english!!! :)
Mauro!


--
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] Require_once problem

2002-11-01 Thread @ Darwin
Well, the way I've read it is that if you use require within control
structures then all files are included, regardless of whether the script
exits before it reaches its next if...elseif...else or case statement. With
include that does not happen. So the general rule of thumb would be to use
require() if you are not using it within these control structures, and use
include() if you actually do need to use include statements in your control
structures. Now, that said, I'm really not sure if that is true for the
require_once and include_once functions also. You might want to look into
that. Hope this helps a little.

-- Darwin

 -Original Message-
 From: Kerry Kobashi [mailto:kkobashi;thegrid.net]
 Sent: Friday, November 01, 2002 1:36 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Require_once problem


 Whats the difference between require_once and include_once?

 I been running into a problem, perhaps someone can help.

 I require_once in a Pear database extension. Inside that pear database
 extension
 is a require_once(pear.php) and a require_once(db.php)

 This file, Thomas Voxs' DbPage.php file, gets require_once inside yet
 another
 file (my file).

 The problem is, my file brings in many require_once file's, some of which
 require_once(db.php) inside of it. All I get redefinition
 problems all over
 the place.

 It appears to me that require_once doesn't work as advertised? For if it
 did,
 there should never be redefinition problems.

 Why didn't all PHP code do like we do in C/C++ with
 #define BLAH
 if !defined(BLAH)
 {
your code here.
 }

 I realize the #define trick works as I used it in my own PHP code... but
 when
 the basic PHP core files don't have this in them, it sort of  makes
 require_once
 and include_once hacks! (that don't work)

 Any ideas suggestions?




 --
 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] Require_once problem

2002-11-01 Thread Ford, Mike [LSS]
 -Original Message-
 From:  Darwin [mailto:superbus22;attbi.com]
 Sent: 01 November 2002 10:17
 
 Well, the way I've read it is that if you use require within control
 structures then all files are included, regardless of whether 
 the script
 exits before it reaches its next if...elseif...else or case 
 statement. With
 include that does not happen. So the general rule of thumb 
 would be to use
 require() if you are not using it within these control 
 structures, and use
 include() if you actually do need to use include statements 
 in your control
 structures.

That's how it *used* to work (somewhere back around 4.0.3, if memory
serves).  Now, the only difference is that the require versions will produce
a fatal error if the file is not present, whereas the include versions will
only generate a warning.

Cheers!

Mike


Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Beckett Park
Tel: extn 4730Fax: extn 3211 

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




[PHP] Require_once problem

2002-10-31 Thread Kerry Kobashi
Whats the difference between require_once and include_once?

I been running into a problem, perhaps someone can help.

I require_once in a Pear database extension. Inside that pear database
extension
is a require_once(pear.php) and a require_once(db.php)

This file, Thomas Voxs' DbPage.php file, gets require_once inside yet
another
file (my file).

The problem is, my file brings in many require_once file's, some of which
require_once(db.php) inside of it. All I get redefinition problems all over
the place.

It appears to me that require_once doesn't work as advertised? For if it
did,
there should never be redefinition problems.

Why didn't all PHP code do like we do in C/C++ with
#define BLAH
if !defined(BLAH)
{
   your code here.
}

I realize the #define trick works as I used it in my own PHP code... but
when
the basic PHP core files don't have this in them, it sort of  makes
require_once
and include_once hacks! (that don't work)

Any ideas suggestions?




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




[PHP] require_once(); questions

2001-07-07 Thread Inércia Sensorial

  Hi All,

  I have a function that includes files based on some SQL queries. On one of
the first loaded files, I want to define a function and use it on another
included file. Something like:

includes file:
first_file.inc.php
This file has: $test = Show me!;

Then include file:
second_file.php
This file has: echo $test;

  But doesn't show nothing, so I guess it is not possible to do. Am I right?
If so, what's the best alternative?

  Also, another question since it is a function that includes the files,
the contents of these files are not available outside the function scope..
what's the best way to use it outside the function?

  Thanks a lot

--


  Julio Nobrega.

A hora está chegando:
http://sourceforge.net/projects/toca




-- 
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]




Re: [PHP] require_once(); questions

2001-07-07 Thread Chris Anderson

Actually this does work:
//First_File.php
?
$test = I am the test variable;
?

//Second_File.php
?
echo $test;
?

//Active file
?
require First_File.php;
require Second_File.php;
?

That would produce the output of :
  I am the test variable

An include or require just places the files' contents at the line you
include it. So after the includes(requires) my parsed code was:
?
$test = I am the test variable;
echo $test;
?

Hope this helps

- Original Message -
From: Inércia Sensorial [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, July 07, 2001 5:59 PM
Subject: [PHP] require_once(); questions


   Hi All,

   I have a function that includes files based on some SQL queries. On one
of
 the first loaded files, I want to define a function and use it on another
 included file. Something like:

 includes file:
 first_file.inc.php
 This file has: $test = Show me!;

 Then include file:
 second_file.php
 This file has: echo $test;

   But doesn't show nothing, so I guess it is not possible to do. Am I
right?
 If so, what's the best alternative?

   Also, another question since it is a function that includes the
files,
 the contents of these files are not available outside the function scope..
 what's the best way to use it outside the function?

   Thanks a lot

 --


   Julio Nobrega.

 A hora está chegando:
 http://sourceforge.net/projects/toca




 --
 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]



-- 
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]




Re: [PHP] require_once(); questions

2001-07-07 Thread Inércia Sensorial

  I guess I know what may be wrong. My function that includes the files, it
is called several times, with different arguments being passed.

  It is something like:

function LoadPositionedModules ($posv, $posh)
{
// $posv is vertical position, and $posh is horizontal position
// Inside it, something like:

SELECT file_to_include FROM table WHERE posv = '$posv' AND posh =
'$posh';

   // Then the fetch_array, include, etc...
}


  So if I call:

LoadPositionedModules ('Left', 'Center');

  And it includes files feeding the SQL. On this included file I define a
var:

$test = Show Me!;

  If I call again, but with different parameters:

LoadPositionedModules ('Left', 'Footer');

  Then I guess the problem is that I can't use the $test var from the first
included file. It's clear to me why I can't now, thanks.

  So I believe a solution would be to find out how to use this var outside
the function scope. That was my second question.. Anyone have any ideas? I
guess I could register it on a session, or return it...

--


  Julio Nobrega.

Yes, I am developing another 'Portal-System'
Have a look:
http://sourceforge.net/projects/toca



-- 
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]




Re: [PHP] require_once(); questions

2001-07-07 Thread Chris Anderson

Try putting GLOBAL infront of the var to give it the greater scope
- Original Message -
From: Chris Anderson [EMAIL PROTECTED]
To: Inércia Sensorial [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, July 07, 2001 8:50 PM
Subject: Re: [PHP] require_once(); questions


 Actually this does work:
 //First_File.php
 ?
 $test = I am the test variable;
 ?

 //Second_File.php
 ?
 echo $test;
 ?

 //Active file
 ?
 require First_File.php;
 require Second_File.php;
 ?

 That would produce the output of :
   I am the test variable

 An include or require just places the files' contents at the line you
 include it. So after the includes(requires) my parsed code was:
 ?
 $test = I am the test variable;
 echo $test;
 ?

 Hope this helps

 - Original Message -
 From: Inércia Sensorial [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Saturday, July 07, 2001 5:59 PM
 Subject: [PHP] require_once(); questions


Hi All,
 
I have a function that includes files based on some SQL queries. On
one
 of
  the first loaded files, I want to define a function and use it on
another
  included file. Something like:
 
  includes file:
  first_file.inc.php
  This file has: $test = Show me!;
 
  Then include file:
  second_file.php
  This file has: echo $test;
 
But doesn't show nothing, so I guess it is not possible to do. Am I
 right?
  If so, what's the best alternative?
 
Also, another question since it is a function that includes the
 files,
  the contents of these files are not available outside the function
scope..
  what's the best way to use it outside the function?
 
Thanks a lot
 
  --
 
 
Julio Nobrega.
 
  A hora está chegando:
  http://sourceforge.net/projects/toca
 
 
 
 
  --
  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]
 


 --
 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]




-- 
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]




[PHP] require_once , include_once Vs irix

2001-05-10 Thread Miguel Loureiro

Hello all,
when I use the functions require_once and include_once in Linux I have no problem (php 
4.0.2), but using it in irix and in older version of php (4.04bl1) I have problems, 
any idea?
Best Regards
Miguel Loureiro [EMAIL PROTECTED]