Last active
November 13, 2015 02:58
-
-
Save igk1972/989a1dd6e10169a88acc to your computer and use it in GitHub Desktop.
Test PHP 5.6 output with always_populate_raw_post_data and DEPRECATED message.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// | |
// Test PHP 5.6 output with always_populate_raw_post_data and DEPRECATED message. | |
// http://php.net/manual/ru/ini.core.php#ini.always-populate-raw-post-data | |
// Run: php -S 127.0.0.0:9090 | |
// Browse: http://localhost:9090 | |
// | |
if (headers_sent()) { | |
die(); | |
} | |
if (!empty($_SERVER['CONTENT_TYPE'])) { | |
header('Content-type: application/json'); | |
echo file_get_contents('php://input').PHP_EOL; | |
die(); | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="https://yastatic.net/jquery/2.1.4/jquery.min.js"></script> | |
</head> | |
<body> | |
<h1>PHP current settings</h1> | |
<?php | |
$options = array( | |
'always_populate_raw_post_data', | |
'display_errors', | |
'display_startup_errors' | |
); | |
foreach ($options as $key) { | |
echo $key.' = '.ini_get($key).'<br/>'.PHP_EOL; | |
} | |
echo 'version = '.phpversion(); | |
?> | |
<br/> | |
<h1>POST-request (application/json)</h1> | |
<div id="result"></div> | |
<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
jQuery.ajaxSetup({ | |
url: '/', | |
method: 'POST', | |
contentType: 'application/json' | |
}); | |
jQuery.ajax({ | |
data: '{"result":"ok"}' | |
}).complete(function(data) { | |
console.log(data); | |
jQuery('#result').html(data.responseText); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment