Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 01-04-2009, 04:33 PM Globals off or not?
magicvw's Avatar
Extreme Talker

Posts: 233
Name: Vicky
Location: Brit in Bulgaria
Trades: 1
New Year's Resolution: Learn PHP

I've made a few attempts at learning PHP recently, half-heartedly. NYR is to study it properly... I've ditched the Dummies book and have started with "Beginning PHP5" by Dave Mercer.

So far so good, but I have just got to a bit about the settings register_globals = Off

I have PHP5 on my website hosts' server, (so thankfully I didn't have to brave the set-up process), but how can I find out what this setting is since it's not on my own server?

I have tried to use bits of script before which did not work, and a quick google suggested that it would be because the register_globals setting was not right for the program. But I can't remember which way it was supposed to be!

I am loathe to go any further with the book if the code won't work unless I can access this setting, as I can't.

Contacting my web host to ask them is really a last resort as I use a Bulgarian company, and the chances of me understanding the answer to this question in English are slim, in Bulgarian I stand no chance!
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
magicvw is offline
Reply With Quote
View Public Profile Visit magicvw's homepage!
 
 
Register now for full access!
Old 01-04-2009, 05:34 PM Re: Globals off or not?
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
If you create a file phpinfo.php with:
PHP Code:
<?php phpinfo();
... and run it in your browser, you can see all of your configuration settings. Just use your browsers "Find in page" feature to search for regsiter_globals.

It is probably on if you are using a shared host. Most experts agree that the option is harmful, but some legacy scripts may depend on it so most shared hosts keep it on. Having it on however does not stop you from writing good, safe, clean code. Basically the setting is only meaningful when you write code that specifically expects this option on (which is always bad code). If you are writing good, secure code, then this option is of little consequence.

It seems doubtful that your book is using code samples that require register_globals, so while you are learning it's unlikely that this setting should make any difference to you at all. But if you have not already, learn about what register_globals actually does.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE


Last edited by Christopher; 01-04-2009 at 07:27 PM..
Christopher is offline
Reply With Quote
View Public Profile
 
Old 01-04-2009, 06:08 PM Re: Globals off or not?
magicvw's Avatar
Extreme Talker

Posts: 233
Name: Vicky
Location: Brit in Bulgaria
Trades: 1
Quote:
Originally Posted by Christopher View Post
If you create a file phpinfo.php with:
PHP Code:
<?php phpinfo();
... and run it in your browser, you can see all of your configuration settings. Just use your browsers "Find in page" feature to search for regsiter_globals.

It is probably on if you are using a shared host. Most experts agree that the option is harmful, but some legacy scripts may depend on it so most shared hosts keep it on. Having it on however does not stop you from writing good, safe, clean code. Basically the setting is only meaningful when you write code that specifically expects this option on (which is always bad code). If you are writing good, secure code, then this option has little consequence.

It seems doubtful that your book is using code samples that require register_globals, so while you are learning it seems unlikely that this setting should make any difference to you at all. But if you have not already, learn about what register_globals actually does.

THANKS!!!

So I have discovered that they are OFF. I guess that's good from a security point of view then? If I understand it correctly, they are dangerous if ON and if I am find a script which says they need to be on I should probably avoid that script anyway?
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
magicvw is offline
Reply With Quote
View Public Profile Visit magicvw's homepage!
 
Old 01-04-2009, 06:25 PM Re: Globals off or not?
Defies a Status

Posts: 1,605
Trades: 0
Note the closing tag was omitted in the post above:

Quote:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 01-04-2009, 07:22 PM Re: Globals off or not?
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Quote:
If I understand it correctly, they are dangerous if ON and if I am find a script which says they need to be on I should probably avoid that script anyway?
That's exactly right These days though it is very very uncommon to find such a script, so you shouldn't worry. Indeed, the register_globals setting will be completely removed in PHP6.

Quote:
Note the closing tag was omitted in the post above:
Purposefully The closing tag is not required, and saves possible headaches to do with trailing whitespace (i.e., "headers already sent" and the like). I never include closing tags unless I have to mix PHP with markup.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 01-04-2009, 08:48 PM Re: Globals off or not?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
Quote:
Originally Posted by Christopher View Post
Purposefully The closing tag is not required, and saves possible headaches to do with trailing whitespace (i.e., "headers already sent" and the like). I never include closing tags unless I have to mix PHP with markup.
Yep!
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 01-05-2009, 04:45 AM Re: Globals off or not?
magicvw's Avatar
Extreme Talker

Posts: 233
Name: Vicky
Location: Brit in Bulgaria
Trades: 1
Quote:
Originally Posted by colbyt View Post
Note the closing tag was omitted in the post above:
Well there you go! I had actually put the closing tag in myself anyway, thinking how clever I was, but it turns out it wasn't necessary!

Thanks again for your help
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
magicvw is offline
Reply With Quote
View Public Profile Visit magicvw's homepage!
 
Old 01-05-2009, 09:56 AM Re: Globals off or not?
Defies a Status

Posts: 1,605
Trades: 0
Later on you will know enough to rework a "global_on" script to make it work in the off mode. For now they are best avoided.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Globals off or not?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32690 seconds with 12 queries