I'm trying to create a web app and I want to make key value pair array. Like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"></meta>
<link rel="stylesheet" type="text/css" href="css/style.css">
<title></title>
<script type="text/javascript" charset="utf-8" src="lib/jquery-1.11.0.js"></script>
<script type="text/javascript" charset="utf-8" src="script/main.js"></script>
</head>
<?php
$data = array('grant_type' => $authorization_code);
// more code goes here
?>
<div class="container">
</div>
</body>
</html>
For some reason, the code above just prints $authorization_code); // more code goes here ?>
So it seems that the execution stops everytime I insert '=>' to the code. This occurs even if '=>' is commented.
Before down voting this please consider I already feel incredibly dumb and I really, really did not find an answer to this by Googling.
EDIT
Added full source.
You haven't quoted either of those values, so PHP is treating them as undefined constants .
Try
$data = array('grant_type' => $authorization_code);
or whatever it really should be instead.
php > $data = array(foo => bar);
PHP Notice: Use of undefined constant foo - assumed 'foo' in php shell code on line 1
PHP Notice: Use of undefined constant bar - assumed 'bar' in php shell code on line 1
php > define('foo', 'hello');
php > define('bar', 'world');
php > $data = array(foo => bar);
php > var_dump($data);
array(1) {
["hello"]=>
string(5) "world"
}
As far as execution stopping goes, =>
shouldn't be a PHP block sentinel value. only ?>
would "shut off" php.
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.