I am working on converting some ancient .php3 code. While running the ancient .php3 version on the ancient box everything works fine. When I click the rewrite button it enters the rewrite if block.
.php3
<?
if($rewrite) {
//here is therewrite code
}
<input class="smButton" type="submit" name="rewrite" value="Save Changes">
.php
<?php
if($rewrite) {
//here is therewrite code
}
<input class="smButton" type="submit" name="rewrite" value="Save Changes">
Is there something obvious that I am missing? Something in the .php3 version sets the rewrite variable but in the new version it isn't set unless I manually set it at the top of the .php file.
Hopefully this is enough code. I am just wondering what could cause such different behaviors between the 2 versions.
PHP | $ vs $$ operator For example, below is a string variable: $var_name = "Hello World!"; The $var_name is a normal variable used to store a value. It can store any value like integer, float, char, string etc. On the other hand, the $$var_name is known as reference variable where $var_name is a normal variable.
The difference is, strings between double quotes (") are parsed for variable and escape sequence substitution. Strings in single quotes (') aren't.
It means you pass a reference to the string into the method. All changes done to the string within the method will be reflected also outside that method in your code. See also: PHP's =& operator.
register_globals is probably on for PHP 3 and off in your newer PHP version (as it should be)
You have to replace the $rewrite
by $_POST['rewrite']
, because your new PHP version doesn't activate register_globals, which translate every $_POST['x']
and $_GET['x']
(and more generally $_REQUEST['x']
) to $x
)
This leads to a bunch of security holes, if you have PHP code of low quality (which can be the case if you haven't maintain it since years).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With