php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10908 Undeclared variables/URL declared variables
Submitted: 2001-05-16 16:56 UTC Modified: 2001-05-16 17:39 UTC
From: jpmaster77 at hotmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.5 OS: WinME
Private report: No CVE-ID: None
 [2001-05-16 16:56 UTC] jpmaster77 at hotmail dot com
Ok, I ran this script on my Apache server with the new PHP 4.0.5 installed and it did not work...

<?

if($id="view"){
echo "You are in view mode";
}
else{
echo "You are not in view mode";
?>

<br>
<form action="?id=view" method="post">
<input type="submit" value="Change to View Mode">
</form>

<?
}
?>

When you first view the page, it says "You are not in view mode" and has a submit button that says "Change to View Mode". If you click to button it will give $id the value of "view", so when it reloads the page, it will display "You are in view mode".

This script works fine on my server with the earlier version of PHP, but not with 4.0.5. The new version 4.0.5 returns an error the first time it loads an says that $id hasnt been defined. 

I dont know if they changed it on the new version because they thought it was a bug of the old versions(that didnt return errors for undeclared variables), but if thats the case, they certainly disabled simple scripts like this one that made things a hell of a lot easier for us programmers. Thats why I'm using the old version of PHP, and not PHP 4.0.5 on my Apache server.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-16 17:07 UTC] derick@php.net
This is not a bug.

1. Use:

if ($id == "view")

= : assignment
== : comparison

2. You can change your errorlevel, which is causing these
   messages, see www.php.net/error_reporting
 [2001-05-16 17:36 UTC] lyric@php.net
Submitter added:
"Oops!  in the code in the above bug report, i made a mistake:  Change   if($id="view")  to   if($id=="view")  Thats how the original code I ran looked like. Sorry for the error, I was typing fast."

Your problem is simply that the error_level (as described by derick) is set higher than you are used to. Still, the code should probably read something like

if (isset($id) && ($id=="view"))

 [2001-05-16 17:39 UTC] derick@php.net
It's not open, it was not a bug, so closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 01:01:30 2024 UTC