Bug #17428 Updated: Fix the tutorial about global variables

From: Date: Mon, 08 Jul 2002 02:01:46 +0000
Subject: Bug #17428 Updated: Fix the tutorial about global variables
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-11189@lists.php.net to get a copy of this message
ID: 17428 Updated by: jacques@php.net Reported By: jim.min@sivacorp.com Status: Open Bug Type: Website problem Operating System: Windows XP PHP Version: 4.2.1 New Comment: Okay I've just done a cvs commit on tut.php which has links to the strstr manual page and the control structure page, as well as changed the variables listed to way they would be set if register_globals=off in the php.ini file. I've implemented some of philip@php.net's suggestions so far. I'll get around to going thru the entire phpweb and changing all the code to use the register_globals=off since newbies also like to view the source code to see how the webteam do various things on the site. Previous Comments: ------------------------------------------------------------------------ [2002-07-07 21:04:04] jacques@php.net I'm currently going to fix this page now. I'm going to ensure that all the examples on the page work. Expect a commit a bit later this morning. ------------------------------------------------------------------------ [2002-07-04 21:54:27] philip@php.net This page needs a complete rewrite, this is still open. Many paragraphs are outdated and written during a time when the register_globals directive didn't even exist (always on). A simple note on the bottom that essentially says: "the above method is not preferred." isn't enough. Complete newbies read tut.php Also, superglobals becaming available in 4.1.0 should be mentioned and linked. And, all examples should work with register_globals = off. Also, for example, $HTTP_USER_AGENT is mentioned in a few places yet this isn't available with register_globals off. And lastly, tut.php needs more links to related man pages. Like the used functions and predefined variables, if statement, forms, etc. ------------------------------------------------------------------------ [2002-06-28 21:03:59] imajes@php.net fixed. ------------------------------------------------------------------------ [2002-06-20 12:39:53] philip@php.net This is a website problem (not in docs) and is rather critical as the explanations in tut.php make it sound as if register_globals is always on in PHP (like in the old days). But the example code now uses predefined vars, which is good. Although it should mention that superglobals came into existence in PHP 4.1.0 ------------------------------------------------------------------------ [2002-05-26 14:15:38] philip@php.net Using import_request_variables() is close, but since it became available in PHP 4.1.0 it's not ideal, and it only deals with GPC. Using extract() will be closer, something like: // register a lot of vars if register_globals = off if (!ini_get('register_globals')) { $types_to_register = array('GET','POST','COOKIE', 'SESSION','SERVER'); foreach ($types_to_register as $type) { if (@count(${'HTTP_' . $type . '_VARS'}) > 0) { extract(${'HTTP_' . $type . '_VARS'}, EXTR_OVERWRITE); } } } This does not rely on the variable_order directive, which I prefer not to do, but it could :) Maybe someone wants to add ENV, or subtract some, or add a prefix. All possabilities to think about. Also note that default for register_globals became "off" in PHP 4.2.0 but as of PHP 4.1.0 it was recommended to have it off. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/17428 -- Edit this bug report at http://bugs.php.net/?id=17428&edit=1

« previous php.mirrors (#11189) next »