Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 9th, 2005, 07:04 AM
Authorized User
 
Join Date: Jan 2005
Location: Siemianowice, , Poland.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Global variables

I try to declare the global variable with the:
global $variable = "";

and the variable is not seen in the other function.

Why??

Yo
__________________
Yo
Reply With Quote
  #2 (permalink)  
Old May 9th, 2005, 09:28 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 117
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi
Can you give us an example?
You mean like this?

$var = 'Name';

function function1
{
  global $var;
}
function function2
{
  global $var;
}


Thanks
Regards

Reply With Quote
  #3 (permalink)  
Old May 10th, 2005, 06:15 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

autoglobales directive is set off in php.ini
It is bad idea to use global variables. But, one good to use these ( particulary define()ed constants ) is by include-ing/require-ing files.

Reply With Quote
  #4 (permalink)  
Old May 10th, 2005, 06:17 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

this directive can be set on per directory level ( Linux/Apache )
Quote:
quote:<IfModule mod_php4.c>
php_flag register_globals On
</IfModule>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
global variables Komila ASP.NET 3.5 Basics 2 October 31st, 2008 01:14 PM
Global Variables in C# su C# 2 December 11th, 2006 06:18 PM
Global variables ps124 ASP.NET 1.0 and 1.1 Basics 6 April 6th, 2004 02:48 PM
Maintaining Global variables tenikiwon Beginning PHP 1 June 19th, 2003 02:11 PM



All times are GMT -4. The time now is 05:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.