简体   繁体   中英

Php 5.4 upgrade to 5.6 : GET variables issues

I created a little website from scratch with Mysql database, PHP Sessions etc... on my local WAMP with PHP 5.4.

When uploading the website files to my online host - which is running PHP 5.6 - I have issues with all the GET variables, it seems to not be functionnal.

On my local computer :

// Requested URL : index.php?title=Hello
<?php

echo $_GET["title"]; // works

?>

On the server :

// Requested URL : index.php?title=Hello
<?php

echo $_GET["title"]; // empty. 

?>

Crazy ! I do not understand what happens... I read the "Migrating from PHP 5.4.x to PHP 5.6.x" and the "Migrating from PHP 5.5.x to PHP 5.6.x" but I don't manage to find what is not working.

Do you have any idea ?

EDIT 01/13 : I created a very simple form page :

<?php
echo $_POST["texttest"]."<hr />";
?>

<form action="?" method="POST">
<input type="text" name="texttest" class="texttest" id="texttest" />
<input type="submit" value="test">
</form>

.. The POST var is never displayed. When I look in the Chrome console after submitting the form, I have a message :

Provisional headers are shown

setup a test script with phpinfo to see what your ini variables are on the host.

<?php
phpinfo();
?>

http://php.net/manual/en/ini.core.php#ini.variables-order if variables-order is set a certain way - $_GET might not be available...

Mine is set to:

; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
; paid for the registration of these arrays and because ENV is not as commonly
; used as the others, ENV is not recommended on productions servers. You
; can still get access to the environment variables through getenv() should you
; need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order
variables_order = "GPCS"

If you have access to your php.ini - you can simply change it.

EDIT: OK - confirmed that variables_order = "GPCS".
if the source test code is edited to this - what is the result?

<?php 
echo 'This is my page'; // should always print- just to make sure you are on the correct page 
echo '$_REQUEST:'.print_r($_REQUEST,true); 
echo '$_GET: '.print_r($_GET,true); 
echo '$_POST: '.print_r($_POST,true); 
echo $_GET["title"]; // empty. 
?>

; Whether PHP will read the POST data. ; This option is enabled by default. ; Most likely, you won't want to disable this option globally. It causes $_POST ; and $_FILES to always be empty; the only way you will be able to read the ; POST data will be through the php://input stream wrapper. This can be useful ; to proxy requests or to process the POST data in a memory efficient fashion. ; http://php.net/enable-post-data-reading enable_post_data_reading = Off

remove ; from first line ;enable_post_data_reading = Off

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM