Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php3 and php Variable Difference

Tags:

php

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.

like image 485
sealz Avatar asked Aug 06 '13 19:08

sealz


People also ask

What is $$ variable in PHP?

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.

Whats the difference between and in PHP?

The difference is, strings between double quotes (") are parsed for variable and escape sequence substitution. Strings in single quotes (') aren't.

What does &$ mean in PHP?

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.


2 Answers

register_globals is probably on for PHP 3 and off in your newer PHP version (as it should be)

like image 73
John Conde Avatar answered Oct 11 '22 17:10

John Conde


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).

like image 34
Maxime Lorant Avatar answered Oct 11 '22 17:10

Maxime Lorant