RE: [PHP] using require or include?
| From: | Graham Cossey | Date: | Thu, 04 Nov 2004 23:47:11 +0000 |
| Subject: | RE: [PHP] using require or include? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201240@lists.php.net to get a copy of this message | ||
Have you looked at the GLOBAL keyword?
http://uk.php.net/manual/en/language.variables.scope.php
> -----Original Message-----
> From: Reinhart Viane [mailto:rv@domos.be]
> Sent: 04 November 2004 23:02
> To: php-general@lists.php.net
> Subject: [PHP] using require or include?
>
>
> i have made a page (overall.php) in which several elements are defined:
> the connection with the database
> a function called session_checker to check if users are logged in
> and a last function(function getuserinfo()) that substracts values from
> the database based on the session variables of the logged in user
>
> Now this last function sets 2 variables eg.
> $username=$row['user_name'];
> $userstatus=$row['user_status'];
> like this i do not have to recall this script on every page but i just
> can do the function at the top of every page
>
> Now on every page of my site I require this file
> require(overall.php);
>
> But it seems that i cannot get the variables outta this file.
> So i can not use $username or $userstatus on the pages.
>
> I think it has something to do with require not passing the variables?
> Off course i can repeat the function script on the top of every page,
> but that's stupid i think.
> Can i use a include without any problems? Or is there a significant
> difference in use and security?
>
> Thx in advance
> Reinhart
>
>
> _____
>
> Reinhart Viane
> <mailto:rv@domos.be> rv@domos.be
> Domos || D-Studio
> Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
> fax +32 15 43 25 26
>
>
> STRICTLY PERSONAL AND CONFIDENTIAL
> This message may contain confidential and proprietary material for the
> sole use of the intended
> recipient. Any review or distribution by others is strictly prohibited.
> If you are not the intended
> recipient please contact the sender and delete all copies.
>
>
>