Re: [PHP] Include/Require limit?

2013-05-30 Thread Julian Wanke

Hi,it outputs a corrupt image (I think the function imagepng)Am 30.05.2013, 11:17 Uhr, schrieb Alex Pojarsky divine.ra...@gmail.com:Hey.Afaik - only in case if your PHP process instance exeeds allowed memory limit.Other then this - explain how does it fail exactly. Any error messages? Errorous behavior?
On Thu, May 30, 2013 at 12:49 PM, Julian Wanke billa...@gmx.at wrote:
Hi,

I use the pretty large Library PHP Image Workshop (http://phpimageworkshop.com/) at my project. It is about 75,5 KB. Everything works fine but if I try to include a 15 KB file with country codes, it fails.

With the other files I easily get over 100 KB inclusion size, so my question;
Is there a size limitation for include?

Best regards

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


-- Erstellt mit Operas E-Mail-Modul: http://www.opera.com/mail/

Re: [PHP] include/require not allowed in classes?

2003-11-17 Thread Pavel Jartsev
Boyan Nedkov wrote:
Initializing data members (var-s) of a class with non-constant values 
is completely legal operation in PHP, so I don't think this could be a 
reason for the problem.

hmmm... PHP manual says something else...

http://www.php.net/manual/en/language.oop.php

In PHP 4, only constant initializers for var  variables are allowed. To 
initialize variables with non-constant values, you need an 
initialization function which is called automatically when an object is 
being constructed from the class. Such a function is called a 
constructor (see below).



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


Re: [PHP] include/require not allowed in classes?

2003-11-14 Thread Pavel Jartsev
Ryan A wrote:
...

class ads_DB extends DB_Sql {
  var $Host = $MR_Host;
  var $Database = $MR_Database;
  var $User = $MR_User;
  var $Password = $MR_Password;
}


I think, Your problem is here. If i remember correctly, then PHP4 
doesn't allow to initialize var-s with non-constant values.

Solutions:

1) Define those connection parameters as constants, i.e.
define( 'MR_Host', some.host ) etc. And use those constants in 
ads_DB-class definition.

2) Create constructor for ads_DB-class and initialize var-s there.

Hope that helps. :)

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


Re: [PHP] include/require not allowed in classes?

2003-11-14 Thread Boyan Nedkov
Ryan, Pavel,

Pavel Jartsev wrote:

Ryan A wrote:

...
 

class ads_DB extends DB_Sql {
  var $Host = $MR_Host;
  var $Database = $MR_Database;
  var $User = $MR_User;
  var $Password = $MR_Password;
}
 

I think, Your problem is here. If i remember correctly, then PHP4 
doesn't allow to initialize var-s with non-constant values.

Initializing data members (var-s) of a class with non-constant values is 
completely legal operation in PHP, so I don't think this could be a reason for 
the problem.

Concerning the original question:

Ryan A wrote:

 Are includes/requires not allowed in classes?
Includes/requires are not allowed inside the class declaration; if you try to do 
that the parser will complain with error message like Parse error: unexpected 
T_INCLUDE_ONCE .. or something similar depending on which include/require 
statement is used.

 if the answer to that is no, then whats wrong in my code?

At first glance I see at least one confusing think in the code provided:

  /* public: constructor */
  function DB_Sql($query = ) {
$this-SetConnectionParameters();

$a0 = 'edoc_'.'ssap';
$a0 = $GLOBALS[strrev($a0)];
$a1 = 'admin'.'_'.'name';
$a1 = $GLOBALS[$a1];
$a2 = 'eciovni';
$a2 = $GLOBALS[strrev($a2)];
$a3 = 'do'.'main';
$a3 = $GLOBALS[$a3];
$a4 = md5($a1.$a3.$a2);
I don't see the point of re-setting values of $a0 .. $a3, perhaps this is a kind 
of debugging action - can't be sure, you should check that by yourself.

Now, possible solution of the problem how to use a global file with connection 
parameters with multiple classes:

1. Include 'connection parameters' file in the file where the class 'ads_DB 
extends DB_Sql' is declared;

2. Add a new manhood (function) to the class 'ads_DB extends DB_Sql' as follows:

  function SetConnectionParameters() {
global $MR_Host, $MR_Database, $MR_User, $MR_Password;
$this-Host =  $MR_Host;
$this-Database = $MR_Database;
$this-User = $MR_User;
$this-Password = $MR_Password;
  }
3. Call this method (function) once in the constructor of the 'ads_DB extends 
DB_Sql' class, like:

  /* public: constructor */
  function DB_Sql($query = ) {
$this-SetConnectionParameters(); // ===

$a0 = 'edoc_'.'ssap';
$a0 = $GLOBALS[strrev($a0)];
$a1 = 'admin'.'_'.'name';
$a1 = $GLOBALS[$a1];
$a2 = 'eciovni';
$a2 = $GLOBALS[strrev($a2)];
$a3 = 'do'.'main';
$a3 = $GLOBALS[$a3];
$a4 = md5($a1.$a3.$a2);
if(($a4 != $a0)  rand(0,1)) { ..
4. See what will happen .. :-))

Hope that helps,

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


Re: [PHP] include/require not allowed in classes?

2003-11-14 Thread Ryan A
Hey guys,
Thanks for replying.

This is the solution that actually works.

class ads_DB extends DB_Sql {
  var $Host = ;
  var $Database = ;
  var $User = ;
  var $Password = ;
  /* public: constructor */
  function ads_DB($query = ) {
   global $MR_Host,$MR_Database,$MR_User,$MR_Password;
   $this-Host = $MR_Host;
   $this-Database = $MR_Database;
   $this-User = $MR_User;
   $this-Password = $MR_Password;
   $this-DB_Sql($query);

Cheers,
-Ryan

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



RE: [PHP] include/require inside of function

2003-07-09 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 09 July 2003 03:44
 
   I finally got it. Thanks. All I needed to do was just 
 define global
 $page_title inside the function to denote that I wanted to use that
 variable.
 
 One other quick question, in my original code (per below) the function
 create_global() was used to create_globals on demand. But 
 this involved a
 lot of jumping, from one function to another just to create 
 the globals on
 demand. Is this efficient (more?? less??) compared to just 
 stating global
 $page_title inside the function?

I don't think create_global() is of any use to you in this situation --
you're just wasting the time taken to do the function call and return. Just
do either:

 function org_display_title_code()
 {
global $page_title;
 
echo 'This is title1 - ' . $page_title;
 }

Or:
 
 function org_display_title_code()
 {
echo 'This is title1 - ' . $GLOBALS['page_title'];
 }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP] include/require inside of function

2003-07-09 Thread Ow Mun Heng
Hi Mike,

I realise that last night. I'm now using $GLOBALS['page_title']

In what situation would create_global() be useful then?

Thanks.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 6:20 PM
To: Ow Mun Heng; Ford, Mike [LSS]
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] include/require inside of function


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 09 July 2003 03:44
 
   I finally got it. Thanks. All I needed to do was just 
 define global
 $page_title inside the function to denote that I wanted to use that
 variable.
 
 One other quick question, in my original code (per below) the function
 create_global() was used to create_globals on demand. But 
 this involved a
 lot of jumping, from one function to another just to create 
 the globals on
 demand. Is this efficient (more?? less??) compared to just 
 stating global
 $page_title inside the function?

I don't think create_global() is of any use to you in this situation --
you're just wasting the time taken to do the function call and return. Just
do either:

 function org_display_title_code()
 {
global $page_title;
 
echo 'This is title1 - ' . $page_title;
 }

Or:
 
 function org_display_title_code()
 {
echo 'This is title1 - ' . $GLOBALS['page_title'];
 }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP] include/require inside of function

2003-07-08 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 07 July 2003 04:34
 
   Here's My question, a variable is not actually global is not
 actually global until I make it global through global 
 $make_this_global
 and then I can assess it using $GLOBAL[$make_this_global].

Not correct.

Variables used in the global scope are global, and appear in the $GLOBALS array as 
soon as they come into existence.  A global statement is used within a function merely 
to declare that you wish to use one of those variables in that function, where it 
would otherwise not be available.  It's sort of equivalent to saying when I use 
variable $x in this function, I actually want it to be $GLOBALS['x'] -- or, in PHP 
terms, $x = $GLOBALS['x'].
 
 
   Another method would be to globalise it on demand by writing a
 little function. (like Rasmus)
 
 I did it like this -- 
 
 
 ---create_globals.php
 function create_global($passed_variable)
 if (isset ($GLOBALS[$passed_variable]))
 {
   return $GLOBALS[$passed_variable];
 }
 ---end-
 
 config.php--
 $page_title = Page Title of Web Page
 -end
 
 --index.html
 require_once ('create_globals.php');
 
 $local_variable = create_global( 'main_title')
 echo My Page Title is.$local_variable;
 --end-
 
 
 Hence This way I can make it global-on-demand. 
 
 Maybe a better way to do it would be to 
 
 ---config.php---
 global $page_title = Alternative Way
 end-

I'm really not sure what you're getting at here, but I think it may be based on a 
misunderstanding.  If you could explain exactly what it is you're trying to do, 
someone might be able to offer some better help.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] include/require inside of function

2003-07-08 Thread Ow Mun Heng
Hi Mike,

Here's the thing.. I declared $page_title = My Page Title in a
file called config.php which is included in the index.php page. when I tried
to - echo $page_title - Nothing comes out. 

If I declared it as global $page_title , then My Page Title would
be echoed out.

That I think is the simplest way to explain it.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 7:11 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] include/require inside of function


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 07 July 2003 04:34
 
   Here's My question, a variable is not actually global is not
 actually global until I make it global through global 
 $make_this_global
 and then I can assess it using $GLOBAL[$make_this_global].

Not correct.

Variables used in the global scope are global, and appear in the $GLOBALS
array as soon as they come into existence.  A global statement is used
within a function merely to declare that you wish to use one of those
variables in that function, where it would otherwise not be available.  It's
sort of equivalent to saying when I use variable $x in this function, I
actually want it to be $GLOBALS['x'] -- or, in PHP terms, $x =
$GLOBALS['x'].
 
 
   Another method would be to globalise it on demand by writing a
 little function. (like Rasmus)
 
 I did it like this -- 
 
 
 ---create_globals.php
 function create_global($passed_variable)
 if (isset ($GLOBALS[$passed_variable]))
 {
   return $GLOBALS[$passed_variable];
 }
 ---end-
 
 config.php--
 $page_title = Page Title of Web Page
 -end
 
 --index.html
 require_once ('create_globals.php');
 
 $local_variable = create_global( 'main_title')
 echo My Page Title is.$local_variable;
 --end-
 
 
 Hence This way I can make it global-on-demand. 
 
 Maybe a better way to do it would be to 
 
 ---config.php---
 global $page_title = Alternative Way
 end-

I'm really not sure what you're getting at here, but I think it may be based
on a misunderstanding.  If you could explain exactly what it is you're
trying to do, someone might be able to offer some better help.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] include/require inside of function

2003-07-08 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 08 July 2003 15:53
 
   Here's the thing.. I declared $page_title = My Page Title in a
 file called config.php which is included in the index.php 
 page. when I tried
 to - echo $page_title - Nothing comes out. 
 
   If I declared it as global $page_title , then My Page 
 Title would
 be echoed out.

And is the assignment in the included file inside a function?  If so, the
usual rules about variables within functions apply.  If not, please post the
relevant code from both files so we can try to figure out your problem.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] include/require inside of function

2003-07-08 Thread Ow Mun Heng
Hi Mike,

I finally got it. Thanks. All I needed to do was just define global
$page_title inside the function to denote that I wanted to use that
variable.

One other quick question, in my original code (per below) the function
create_global() was used to create_globals on demand. But this involved a
lot of jumping, from one function to another just to create the globals on
demand. Is this efficient (more?? less??) compared to just stating global
$page_title inside the function?


Please enlighten me.


---config---
$page_title = Main Page Title;
--

---functions-
function display_title()
{
global $page_title;   This was what I missed
echo $page_title;
}

function org_display_title_code()  --- That was what I used originally
{
$l_main_title = create_globals( 'page_title' );

echo 'This is (create global) title1 - ' . $l_main_title  ;
}

function create_globals( $passed_option )
{
if ( isset( $GLOBALS[$passed_option] ) )
{
return  $GLOBALS[$passed_option];
}
}

---

--index.php--
?php
display_title();
?



Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 11:34 PM
To: Ow Mun Heng
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] include/require inside of function


 -Original Message-
 From: Ow Mun Heng [mailto:[EMAIL PROTECTED]
 Sent: 08 July 2003 15:53
 
   Here's the thing.. I declared $page_title = My Page Title in a
 file called config.php which is included in the index.php 
 page. when I tried
 to - echo $page_title - Nothing comes out. 
 
   If I declared it as global $page_title , then My Page 
 Title would
 be echoed out.

And is the assignment in the included file inside a function?  If so, the
usual rules about variables within functions apply.  If not, please post the
relevant code from both files so we can try to figure out your problem.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP] include/require inside of function

2003-07-06 Thread Ow Mun Heng
Hmm..

Funny I was having this same problem yesterday and wanted to post.

Here's My question, a variable is not actually global is not
actually global until I make it global through global $make_this_global
and then I can assess it using $GLOBAL[$make_this_global]. 

Another method would be to globalise it on demand by writing a
little function. (like Rasmus)

I did it like this -- 


---create_globals.php
function create_global($passed_variable)
if (isset ($GLOBALS[$passed_variable]))
{
return $GLOBALS[$passed_variable];
}
---end-

config.php--
$page_title = Page Title of Web Page
-end

--index.html
require_once ('create_globals.php');

$local_variable = create_global( 'main_title')
echo My Page Title is.$local_variable;
--end-


Hence This way I can make it global-on-demand. 

Maybe a better way to do it would be to 

---config.php---
global $page_title = Alternative Way
end-

then I can -echo This is an .$page_title; and it'll come out as - This
is an alternative way

The only problem here would be the EXTRA typing involved. The other
problem/question is, will there be a speed tradeoff? If I were to global'ise
everything at the 1st place, would it be faster than jumping in and out of
create_global() and going through $page_title  whatever other variables? (I
want to make all global configurations in this file so it'll be easy to
change)

Any help is appreciated.


Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia 
DID : 03-7870 5168


-Original Message-
From: Greg Beaver [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 05, 2003 12:39 AM
To: Rasmus Lerdorf
Cc: Aric Caley; [EMAIL PROTECTED]
Subject: Re: [PHP] include/require inside of function


Hi,

If the file you are including is of your own authorage (I know that 
isn't a word, but whatever :), just refer to global variables always as 
an index of the $GLOBALS array.  This is good practice anyways for any 
file that might be included by another user, for exactly this issue.

I have a file that could be a global include or not in my project, and 
making sure every global variable is referenced as $GLOBALS['varname'] 
fixed it for me without any fancy code (although Rasmus's code is very nice)

Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org

Rasmus Lerdorf wrote:
 On Fri, 4 Jul 2003, Aric Caley wrote:
 
Is there anyway to include a file inside of a function and have the
included
stuff be global?  For instance if I defined a class or a function in that
include file, I want to be able to use that class outside of the function.

On the documentation for include() a poster commented that it did indeed
work like this, but my testing indicates it does not.  Everything stays
local to the function and goes away when the function ends.

Is there a way?
 
 
 Functions defined in included files are always global.  So I guess it is
 just the variable you want to put out into the global symbol table.  It's
 a little bit tricky, but you can do it like this:
 
 function foo($filename) {
 extract($GLOBALS, EXTR_REFS);
 include $filename;
 $arr = array_diff(get_defined_vars(),$GLOBALS);
 foreach($arr as $var=$val) $GLOBALS[$var] = $val;
 }
 
 -Rasmus



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



Re: [PHP] include/require inside of function

2003-07-04 Thread Rasmus Lerdorf
On Fri, 4 Jul 2003, Aric Caley wrote:
 Is there anyway to include a file inside of a function and have the included
 stuff be global?  For instance if I defined a class or a function in that
 include file, I want to be able to use that class outside of the function.

 On the documentation for include() a poster commented that it did indeed
 work like this, but my testing indicates it does not.  Everything stays
 local to the function and goes away when the function ends.

 Is there a way?

Functions defined in included files are always global.  So I guess it is
just the variable you want to put out into the global symbol table.  It's
a little bit tricky, but you can do it like this:

function foo($filename) {
extract($GLOBALS, EXTR_REFS);
include $filename;
$arr = array_diff(get_defined_vars(),$GLOBALS);
foreach($arr as $var=$val) $GLOBALS[$var] = $val;
}

-Rasmus

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



Re: [PHP] include/require inside of function

2003-07-04 Thread Tom Rogers
Hi,

Friday, July 4, 2003, 5:11:18 PM, you wrote:
AC Is there anyway to include a file inside of a function and have the included
AC stuff be global?  For instance if I defined a class or a function in that
AC include file, I want to be able to use that class outside of the function.

AC On the documentation for include() a poster commented that it did indeed
AC work like this, but my testing indicates it does not.  Everything stays
AC local to the function and goes away when the function ends.

AC Is there a way?

One trick that works in php-4.X.X is to put your function inside a
class, as any sub functions become global (invisible to the rest of the
class though :) but that should not matter). Not sure whether it will
be the same in php-5.

a quick example (ignore my filenames it was just to prove it works)

?php
class loadClass {
function loadClass(){
//nothing to do yet;
}
function load($inc){
include($inc);
}
}
$l = new loadClass();
$l-load('templateClass.inc');
$t = new kwikTemplateClass('./');
$variables = array();
echo $t-processFile('layout.htm',$variables);
?

This loads the class I need and it is automatically global..

-- 
regards,
Tom


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



Re: [PHP] include/require inside of function

2003-07-04 Thread Greg Beaver
Hi,

If the file you are including is of your own authorage (I know that 
isn't a word, but whatever :), just refer to global variables always as 
an index of the $GLOBALS array.  This is good practice anyways for any 
file that might be included by another user, for exactly this issue.

I have a file that could be a global include or not in my project, and 
making sure every global variable is referenced as $GLOBALS['varname'] 
fixed it for me without any fancy code (although Rasmus's code is very nice)

Regards,
Greg
--
phpDocumentor
http://www.phpdoc.org
Rasmus Lerdorf wrote:
On Fri, 4 Jul 2003, Aric Caley wrote:

Is there anyway to include a file inside of a function and have the included
stuff be global?  For instance if I defined a class or a function in that
include file, I want to be able to use that class outside of the function.
On the documentation for include() a poster commented that it did indeed
work like this, but my testing indicates it does not.  Everything stays
local to the function and goes away when the function ends.
Is there a way?


Functions defined in included files are always global.  So I guess it is
just the variable you want to put out into the global symbol table.  It's
a little bit tricky, but you can do it like this:
function foo($filename) {
extract($GLOBALS, EXTR_REFS);
include $filename;
$arr = array_diff(get_defined_vars(),$GLOBALS);
foreach($arr as $var=$val) $GLOBALS[$var] = $val;
}
-Rasmus


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


Re: [PHP] include/require vs performance

2003-01-03 Thread Rasmus Lerdorf
 Is there, was there ever issue around including a lot files via
 include(). I am running things on a local server so it's hard to gauge.

I don't understand that comment.  includes/requires are always (well
nearly anyway) local to the server regardless of where the request is
coming from.  So if you have a test box and it is fast enough for you,
then go with it.

-Rasmus

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




Re: [PHP] include/require vs performance

2003-01-03 Thread Michael J. Pawlowsky

These files are parsed by the interpreter...
They are not sent to the client, so I you are thinking bandwidth I dont see how it 
would affect it.
Unless they all output a bunch of data.

Of course there will be some overhead for PHP to interpret all that code.

Mike



*** REPLY SEPARATOR  ***

On 03/01/2003 at 8:25 AM Radek Zajkowski wrote:

i am designing a small app that obviuosly works best when I have a lot of
global files with functions, which cut down on editing.

I will likely have a main page that will contain modules and also load
all of the required includes like config etc. in total some 10 files will
be reqested.

Is there, was there ever issue around including a lot files via
include(). I am running things on a local server so it's hard to gauge.

Thansk in advance.

R

___
Radoslaw Zajkowski
http://www.finalbanana.com


--
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/require vs performance

2003-01-03 Thread Marek Kilimajer
He likely ment that his local server is simply fast enough that any 
speed defference is unnoticeable,
but on a shared host this might make some difference.
Use include/require as you are more comfortable with it.

Rasmus Lerdorf wrote:

Is there, was there ever issue around including a lot files via
include(). I am running things on a local server so it's hard to gauge.
   


I don't understand that comment.  includes/requires are always (well
nearly anyway) local to the server regardless of where the request is
coming from.  So if you have a test box and it is fast enough for you,
then go with it.

-Rasmus

 



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




Re: [PHP] include/require vs performance

2003-01-03 Thread R . Z .
Sorry if this was not 100% clear. In a nutshell the app I'm making will 
be available for poeple to use. My feeling is that there will be users 
using shared servers, which under a stress tend to suck. The only thing 
in this one I'm doing that;s new to me is having some 20 includes loaded 
as I need them, sometimes up to 10 at a time, hence the concern.

Thanks for all your responses, I got enough info to go on. ANother words, 
this should not be a problem.

R

http://sourceforge.net/projects/athena-research

 Is there, was there ever issue around including a lot files via
 include(). I am running things on a local server so it's hard to gauge.

I don't understand that comment.  includes/requires are always (well
nearly anyway) local to the server regardless of where the request is
coming from.  So if you have a test box and it is fast enough for you,
then go with it.

-Rasmus

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


___
Radoslaw Zajkowski
http://www.finalbanana.com


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




Re: [PHP] Include/require and the HTML Code

2002-08-14 Thread Sascha Braun

Maybe something wrong with the return?

I was thinking about return What?. (U understand me?)

in Javascript a simple return does nothing. maybe you can just leave the
return out of your script.



- Original Message -
From: Mike Eales [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 14, 2002 10:44 AM
Subject: [PHP] Include/require and the HTML Code


 Hi,

 Can anybody tell me why I get a Parse error: parse error,
 unexpected '}' in /usr/local/apache/htdocs/logbook/Functions.inc on line
 17 
 for the following code:

 Appreciate any help.

 Using PHP 4.2.2 and Apache 1.3.26 on Redhat 7.3 x86

 (The  stuff is not part of the code. index.php and
 Functions.inc exists in the same dir)

  File: index.php 
 ?
 require('./Functions.inc');

 HtmlHeader();

 # Do things

 HtmlFooter();

 ?

  End of file 


  File: Functions.inc
 
 function HtmlHeader()
 {
 ?

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 htmlhead
 meta http-equiv=Content-Type content=text/html;
 charset=iso-8859-1
 titleLogBook/title
 /head

 body bgcolor=#FF text=#00 link=#FF
 vlink=#80 alink=#FF

 ?

 return;
 } --- This is line 17, the error point..


 function HtmlFooter()
 {
 ?
 /body /html

 ?

 return;
 }

  End of file 


 Thanks
 Mike.



 --
 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/require and the HTML Code

2002-08-14 Thread Bas Jobsen

 Can anybody tell me why I get a Parse error: parse error,
 unexpected '}' in /usr/local/apache/htdocs/logbook/Functions.inc on line

begin and end your include files with ? and ?
?
 function HtmlHeader()
 {
 ?
bllaalla

?
return;
}
?


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




RE: [PHP] Include/require and the HTML Code

2002-08-14 Thread Peter Houchin

Mike,

i had no problems with this..


!-- index.php --
?
 include('Functions.inc');

 HtmlHeader();
?
 # Do things
?
 HtmlFooter();

 ?


!-- Functions.inc--
?
function HtmlHeader()
 {
 ?

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 htmlhead
 meta http-equiv=Content-Type content=text/html;
charset=iso-8859-1
 titleLogBook/title
 /head

 body bgcolor=#FF text=#00 link=#FF
vlink=#80 alink=#FF

 ?

 return;
 }
?
?
 function HtmlFooter()
 {
 ?
 /body /html

 ?

 return;
 }

cheers
Peter


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




RE: [PHP] Include/require and the HTML Code

2002-08-14 Thread Michael Eales


This did indeed fix the problem, thanks for the advise.

A question though:
Why is this necessary, the include/require is called from index.php while in
PHP mode ?
The functions work fine as if I remain in PHP mode within the functions.
It is only when I go in and out of HTML mode within the function that this
problem arises.

Thanks again
Mike.

-Original Message-
From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 15 August 2002 6:52 AM
To: Mike Eales; [EMAIL PROTECTED]
Subject: Re: [PHP] Include/require and the HTML Code


 Can anybody tell me why I get a Parse error: parse error,
 unexpected '}' in /usr/local/apache/htdocs/logbook/Functions.inc on line

begin and end your include files with ? and ?
?
 function HtmlHeader()
 {
 ?
bllaalla

?
return;
}
?


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




Re: [PHP] Include/require and the HTML Code

2002-08-14 Thread Chris Shiflett

I'm not sure about others, but I am glad this behavior is like this.

It is very nice for modules to stand on their own so to speak, so that 
you don't have to worry about what context they are used in. If the file 
you are including is plain HTML, would you want it to be parsed as if it 
were PHP? No, but if you had to include PHP in it (the closing ? for 
example), it wouldn't be a plain HTML file anymore. You might have other 
applications in different languages using the same module that would now 
have to interpret PHP.

On the other hand, what about a PHP script that you want to include. 
Wouldn't it be annoying to get a parse error when you include it because 
of the double opening tags?

Those are just a few thoughts.

Happy hacking.

Chris

Michael Eales wrote:

This did indeed fix the problem, thanks for the advise.

A question though:
Why is this necessary, the include/require is called from index.php while in
PHP mode ?
The functions work fine as if I remain in PHP mode within the functions.
It is only when I go in and out of HTML mode within the function that this
problem arises.



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




Re: [PHP] include require directive

2002-08-13 Thread James Green

On Tue, 2002-08-13 at 02:55, Huy wrote:
 But I do...
 
 If I left out the require statement all is well.. or I copy the whole
 content of the included file.. it works fine. The problem is the require
 statement.

Check the file for whitespace, anything outside ?..?php or
spaces/blank lines above your first ?php in any of your files.

James.



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




Re: [PHP] include require directive

2002-08-13 Thread Huy

Thanks,

I thought I checked that already. Obviously, I use notepad in Win2000 to
edit the files, and save them as Unicode file, which Notepad put some
characters at the beginning of the file. Only when I use another editor was
I able to see those strange characters. After deleting them, the require
statement works fine. Again, thanks for the help. :)

James Green [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, 2002-08-13 at 02:55, Huy wrote:
  But I do...
 
  If I left out the require statement all is well.. or I copy the
whole
  content of the included file.. it works fine. The problem is the require
  statement.

 Check the file for whitespace, anything outside ?..?php or
 spaces/blank lines above your first ?php in any of your files.

 James.





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




Re: [PHP] include require directive

2002-08-13 Thread Miles Thompson

Huy,

Use Editplus, or something similar, not Notepad. Costs $45 and makes your 
work *much* easier.

Miles


At 08:41 AM 8/13/2002 -0700, Huy wrote:
Thanks,

I thought I checked that already. Obviously, I use notepad in Win2000 to
edit the files, and save them as Unicode file, which Notepad put some
characters at the beginning of the file. Only when I use another editor was
I able to see those strange characters. After deleting them, the require
statement works fine. Again, thanks for the help. :)

James Green [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Tue, 2002-08-13 at 02:55, Huy wrote:
   But I do...
  
   If I left out the require statement all is well.. or I copy the
whole
   content of the included file.. it works fine. The problem is the require
   statement.
 
  Check the file for whitespace, anything outside ?..?php or
  spaces/blank lines above your first ?php in any of your files.
 
  James.
 
 



--
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 require directive

2002-08-12 Thread James Green

On Mon, 2002-08-12 at 22:14, Huy wrote:
 If I use either the include or require statement, PHP will generate some
 lines in the browser. For example, I want the first line is Hello There..
 echo (Hello There); but the line happens to be the third line after some
 blank lines. So how do I turn that off??

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

Enclose your included scripts in ?php ... ?

James



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




Re: [PHP] include require directive

2002-08-12 Thread Huy

But I do...

If I left out the require statement all is well.. or I copy the whole
content of the included file.. it works fine. The problem is the require
statement.

James Green [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Mon, 2002-08-12 at 22:14, Huy wrote:
  If I use either the include or require statement, PHP will generate some
  lines in the browser. For example, I want the first line is Hello
There..
  echo (Hello There); but the line happens to be the third line after
some
  blank lines. So how do I turn that off??

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

 Enclose your included scripts in ?php ... ?

 James





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




RE: [PHP] Include/require

2002-06-20 Thread Michael Sweeney

Be careful not to get confused between a chrooted environment like the
web server or ftp server and php include paths. PHP handles the include
and require parameters either as absolute (eg /inc/filename is an
absolute path from / - it is not relative to the web docroot.) or
relative to the directories in the php.ini include directive. If you
want to simplify your include and require statements, specify the path
to 'inc' in php.ini and then express the paths to the included files
relative to that.

..michael..

On Wed, 2002-06-19 at 22:43, David Freeman wrote:
 
   Is there a way to make include()/require() take a a full
   virtual path?  I.e.  require_once(/inc/myinc.php)?  It gets
   a little annoying to do require(../../../../file.php).
 
 Sure, they should work either way.  The only real gotcha is knowing what
 a full path will be in relation to the web server when it goes to do the
 include/require.  For example, an include for '/inc/myinc.php' has
 particular meaning under *nix that may have it not work even though it
 looks that way to an ftp proggy.
 
 Part of my normal configuration file for php projects is a declaration
 of $webroot as the path to a document as called from within a browser
 (ie. $webroot = http://www.some.domain/some/directory;) and $fileroot
 as the path to a document as called from the filesystem (ie. $fileroot =
 /home/some/user/directory) and then just append as appropriate (ie.
 Include($fileroot/inc/someinclude.php) and away you go.
 
 CYA, Dave
 
 
 
 
 -- 
 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, require, require_once

2001-07-21 Thread Maxim Maletsky

as of PHP v 4.0.(2/4?) require() and include() behave in the exactly same
way.

include_once() and require_once() have the only difference from include()
and require() - they check whether the file was already parsed within the
script or the other included files. If it was the include is ignored.


Sincerely,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com




-Original Message-
From: Martin Marconcini [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 21, 2001 11:54 AM
To: 'Thiago Locatelli da Silva'; [EMAIL PROTECTED]
Subject: RE: [PHP] include, require, require_once


 Subject: [PHP] include, require, require_once

 what is the diference beetwen this functions?

The difference is well explained on www.php.net - documentation -
{include, require, require_once}

RTFM!

Martin.


--
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] include, require, require_once

2001-07-21 Thread Jeff Lewis

Lets not destroy the user community now :(  All the time I hear Perl users
are mea and rude  The PHP community is great.  I am just picking up JSP
(have to, for work) and can't stand their manuals and their users aren't
always as nice.

Lets keep PHP nice and friendly ;)  Yes it is in the manual but it helps
someone new to the language to hear from people who have been using PHP for
some time and their preferences...

Jeff

 -Original Message-
 From: Martin Marconcini [mailto:[EMAIL PROTECTED]]
 Sent: Friday, July 20, 2001 10:54 PM
 To: 'Thiago Locatelli da Silva'; [EMAIL PROTECTED]
 Subject: RE: [PHP] include, require, require_once

 The difference is well explained on www.php.net - documentation -
 {include, require, require_once}

 RTFM!

 Martin.


-- 
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] include, require, require_once

2001-07-21 Thread Martin Marconcini

 Lets not destroy the user community now :(  All the time I hear Perl
 users
 are mea and rude  The PHP community is great.  I am just picking up
JSP
 (have to, for work) and can't stand their manuals and their users
aren't
 always as nice.
 
 Lets keep PHP nice and friendly ;)  Yes it is in the manual but it
helps
 someone new to the language to hear from people who have been using
PHP
 for
 some time and their preferences...
 
 Jeff

I apologize. Too much openbsd misc ;0

Martin.


-- 
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] include, require, require_once

2001-07-20 Thread Joshua Pierre

Hi,

On Sat, Jul 21, 2001 at 12:18:38AM -0300, Thiago Locatelli da Silva wrote:
 what is the diference beetwen this functions?

I believe the include/require_once() functions check to see if that particular include 
was previously included in the script and if it was it ignores it, at least that is 
the way I understand it.

require() differrs from include() because it will always read the targetted file even 
if the line of code it is sitting on is never actually executed.

Hope that describes it for you.

Regards,

Josh
--
First post to list :)

-- 
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] include, require, require_once

2001-07-20 Thread Martin Marconcini

 Subject: [PHP] include, require, require_once
 
 what is the diference beetwen this functions?

The difference is well explained on www.php.net - documentation -
{include, require, require_once}

RTFM!

Martin.


-- 
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] Include / Require

2001-04-05 Thread Lindsay Adams

On 4/5/01 10:56 AM, "Ashley M. Kirchner" [EMAIL PROTECTED] wrote:

 
   I have a DB project going and every time I query the DB for data
 from a particular table, I want to include a set of variables (that get
 set based on the query result).  I was thinking of doing something like
 this:
 
   $sql = "..."
   $result = ;
   include 'variables.php?table=$table';
 
   However, every time I try that, it tells me it can't find
 'variables.php'.  However, if I rename the file to 'variables.inc', it
 does find it (though it doesn't pass any arguments to it then).
 
   The first method tells me it's not in the include path.  Okay,
 easily fixable in php.ini, however, I don't want this extra path info to
 apply to the whole server (which is running several vhosts).  How can I
 adjust the include path just for this particular vhost?
 
   Or, is there a better way to do what I'm trying to accomplish?  Make
 it a function perhaps?  A call that would look kinda like this perhaps:
 variables($table) ?  But then, how do I get to the actual variables?
 
   AMK4
 

Ashley,

You don't really need to pass the values in your include.
All that include does is insert the file inine, as if it was written there.

So, leaving out the table=$table will still result in $table being defined
by the code prior to the include.

Ie.
$table="value or array or whatever"

Include("file that references $table.php");

// $table is still  in the global namespace, and the include file can
reference it as normal.

The only way you would need to pass values to the php file, like you did, is
if you were retrieving data from it through
fopen("http://domain.com/variables.php?table=$table",'r');

Include does not pre parse your file.

Hope that helps.


-- 
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] Include / Require

2001-04-05 Thread Johnson, Kirk

In addition to Lindsay's comments: 

Any time PHP can't include() a file, but it can include() it if you change
the filename, check the permissions on the original file. They may be set
too restrictive for PHP to read it.

Kirk

 -Original Message-
 From: Ashley M. Kirchner [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 05, 2001 11:57 AM
 To: PHP-General List
 Subject: [PHP] Include / Require
 
 However, every time I try that, it tells me it can't find
 'variables.php'.  However, if I rename the file to 'variables.inc', it
 does find it (though it doesn't pass any arguments to it then).

-- 
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] Include / Require

2001-04-05 Thread Chris Lee

is the file localhost? because the file being localhost or remote makes a huge 
difference. lets assume its localhost

incdex.php
?php
$table = 'test';
include_once("$DOCUMENT_ROOT/include/variables.php");
?

now, variables.php will NOT return variables, thats not what is for. it just includes 
the code, thats it.

variables.php
?php
if ($table == 'test')
echo "do something...";
else
echo "do something else...";
?

there you. include does NOT return variables. imagine it like this, imagine you opened 
variables.php in your editor, and cut and paste all that code right exactly where 
include_once(...) was, thats what php is doing.

now

include_once("http://somedomain.com/variables.php");

is very very different, this will send and HTTP request for the page, local variables 
will not be seen by variables.php any variables set in variables.php will not be 
returened either.

include_once("http://somedomain.com/variables.php?table=test");

this will send the variable table to variables.php but variables.php will still not be 
able to return anything. using include_once(..) this way has limited usfullness. not 
saying its not usfull, just saying its limited.


-- 

 Chris Lee
 [EMAIL PROTECTED]





""Ashley M. Kirchner"" [EMAIL PROTECTED] wrote in message 
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
Lindsay Adams wrote:

 So, leaving out the table=$table will still result in $table being defined
 by the code prior to the include.

Actually, the the I'm trying to include has several segments in it, which
depend on which table was just queries.  It basically looks like this:

if (table_1) {
return this set of variables
} elseif (table_2) {
return this other set
} elseif (table_3) {
return these ones
} else {
echo "you bonehead, you didn't include a table!";
}

You're saying, if I just include 'variables.inc', it will know what $table
is (from the main script) and would run through that routine fine?  Actually, it
makes sense, all it does is include it as if I wrote it in the main script.
Okay, so how can I make it so I only get the variables returned, as opposed to
it including the whole bit in the main script?  (kinda like the way a function()
with a return $var in it would work.)

AMK4

--
W |
  |  I haven't lost my mind; it's backed up on tape somewhere.
  |
  ~
  Ashley M. Kirchner mailto:[EMAIL PROTECTED]   .   303.442.6410 x130
  SysAdmin / Websmith   . 800.441.3873 x130
  Photo Craft Laboratories, Inc. .eFax 248.671.0909
  http://www.pcraft.com  . 3550 Arapahoe Ave #6
  .. .  .  . .   Boulder, CO 80303, USA



-- 
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] include() require()

2001-03-07 Thread Derek Sivers


Which is the main difference between include() and
require() functions?


"include" is optional
you can put it inside an "IF"
like this:

if (0)
   {
   /* THIS WILL NOT SHOW... */
   include "optional_file.php";
   }


but "require" happens every time,
even if it is inside an "IF" that does not happen.

if (0)
   {
   /* THIS WILL SHOW ANYWAY... */
   require "optional_file.php";
   }


Me personally,
I use "require" to include functions, libraries, classes that I NEED to run 
the page.
Then I use "include" for optional things, based on "if".


?
require "functions.inc";

if ($sunny_day)
   {
   include "sunny_day_message.txt";
   }

?


-- 
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] include() require()

2001-03-07 Thread Zeev Suraski

At 13:41 7/3/2001, Derek Sivers wrote:

Which is the main difference between include() and
require() functions?


"include" is optional
you can put it inside an "IF"
like this:

if (0)
   {
   /* THIS WILL NOT SHOW... */
   include "optional_file.php";
   }


but "require" happens every time,
even if it is inside an "IF" that does not happen.

if (0)
   {
   /* THIS WILL SHOW ANYWAY... */
   require "optional_file.php";
   }


That's actually no longer true, in more recent versions of PHP (it used to 
be true).  The only difference between include() and require() is that 
require() will bail out if it fails, whereas include() would not.

Zeev


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