Connecting Tech Pros Worldwide Forums | Help | Site Map

including files

Michael G
Guest
 
Posts: n/a
#1: Aug 13 '05
A habit of mine is to include all files at the head of the file requiring
them.
Is the following bad practice? It works just fine but...???

thanks, mike

class ActionFactory
{
function createAction($className)
{
$className = $className.'Action';

include_once 'action/'.$className.'.php';

return new $className;
}
}



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Michael G
Guest
 
Posts: n/a
#2: Aug 13 '05

re: including files



"Michael G" <mike-g@montana.com> wrote in message
news:1123965413_1221@spool6-east.superfeed.net...[color=blue]
>A habit of mine is to include all files at the head of the file requiring
>them.
> Is the following bad practice? It works just fine but...???
>
> thanks, mike
>
> class ActionFactory
> {
> function createAction($className)
> {
> $className = $className.'Action';
>
> include_once 'action/'.$className.'.php';
>
> return new $className;
> }
> }[/color]


It seems like this would cause some scope problems?

Mike



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Michael G
Guest
 
Posts: n/a
#3: Aug 13 '05

re: including files



"Michael G" <mike-g@montana.com> wrote in message
news:1123965731_1225@spool6-east.superfeed.net...[color=blue]
>
> "Michael G" <mike-g@montana.com> wrote in message
> news:1123965413_1221@spool6-east.superfeed.net...[color=green]
>>A habit of mine is to include all files at the head of the file requiring
>>them.
>> Is the following bad practice? It works just fine but...???
>>
>> thanks, mike
>>
>> class ActionFactory
>> {
>> function createAction($className)
>> {
>> $className = $className.'Action';
>>
>> include_once 'action/'.$className.'.php';
>>
>> return new $className;
>> }
>> }[/color]
>
>
> It seems like this would cause some scope problems?
>[/color]

from http://us2.php.net/function.include
When a file is included, the code it contains inherits the variable scope of
the
line on which the include occurs. Any variables available at that line in
the
calling file will be available within the called file, from that point
forward.
However, all functions and classes defined in the included file have the
global scope.



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Closed Thread