Re: [PHP] conditionaly including classes/functions

2002-04-05 Thread Erik Price


On Thursday, April 4, 2002, at 12:28  PM, Andrew Warner wrote:

> Is it okay practice to condtionally include php files that contain only 
> classes or functions (as opposed to just straight code)?   The result 
> is a class or function inserted right in the middle of an if{} block:

It is better to do so, since you don't waste the processor's time with 
the function/class or include() process if you don't really need it.

However, it can be tricky making sure that these libraries are available 
to your code, since there is now a condition determining whether or not 
it will be processed.


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




[PHP] conditionaly including classes/functions

2002-04-05 Thread Andrew Warner

Is it okay practice to condtionally include php files that contain 
only classes or functions (as opposed to just straight code)?   The 
result is a class or function inserted right in the middle of an if{} 
block:


} elseif ($var=='a')
{
 include('temp.php');

 $obj = new foo;
 echo $obj->hello();

}


The above code expanded looks like this (below). Works, but it seems 
wierd to be able to have a class in the middle of an if{} code block.


} elseif ($var=='a')

 class foo
 {
function hello()
{
return "Hello";
}
 }

 $obj = new foo;
 echo $obj->hello();

}

Andrew

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