note 51980 added to function.preg-replace
| From: | jcscott at scottcomm dot com | Date: | Sun, 17 Apr 2005 22:17:20 +0000 |
| Subject: | note 51980 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88134@lists.php.net to get a copy of this message | ||
Don't know if this a bug or not, but using a Windows NT localhost 5.0 build 2195 (PHP 4.3.1) I
noticed that preg_replace will actually replace a $GLOBALS variable rather than making the
replacement just to a new variable, ie:
<?php
$GLOBALS['mainurl'] = "http://www.website.com/";
//remove last slash
$mainurl = preg_replace("|/$|", "", $GLOBALS['mainurl']);
?>
results in
$GLOBALS['mainurl'] = "http://www.website.com"
and
$mainurl = "http://www.website.com"
I'm under the impression that $GLOBALS variables are distinct from local variables of the same
name. Then again, I could be wrong.
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51980
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51980&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51980&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51980&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51980&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51980&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51980&report=yes
Search -- http://master.php.net/manage/user-notes.php