开发者

how do i install json in xampp server? [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 12 years ago.

开发者_如何学Python Improve this question

How do I install json in xampp server?


Json is a format; you don't install it, you implement it.


If you want to use the json format in your php website, there's an extension that provides functions you can use to encode data in a json format.

To install or use the extension, please see the installation page; depending on your version of php you may have the json extension already bundled with xampp. If you've got the latest version of xampp (windows install), it's ok to use the methods directly


Xampp is "shipped" with Apache, MySQL, PHP, Perl and support for JSON in PHP and Perl!

Json PHP

Json Perl: JSON::to_json(hash);

Simple PHP example from php.net

<?php
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);

echo json_encode($arr);
?>

EDIT: Second example showing how to json_encode() a mysql query result:

<?php
$sth = mysql_query("SELECT ...");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
    $rows[] = $r;
}
print json_encode($rows);
?>

EDIT 2: You are then able to convert JSON to XML using one of the described methods from this stackoverflow question.

Edit3: If you want to save the xml file to disc use

$myFile = "file.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
$data = x;           // replace x with the xml from your ajax result !!!!!
fwrite($fh, $data);
fclose($fh);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜