Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何输出正斜杠_Php_Json_Variables - Fatal编程技术网

Php 如何输出正斜杠

Php 如何输出正斜杠,php,json,variables,Php,Json,Variables,我有一个简单的问题要解决 我需要像这样得到输出到回显url地址 "image": "http://test.info/json/movies/1.jpg" 我一直在用这个密码 <?php include_once 'db_functions.php'; $db = new DB_Functions(); $products = $db->getAllProducts(); $a = array(); $b = array(); $c = 'test.info/json/movies

我有一个简单的问题要解决

我需要像这样得到输出到回显url地址

"image": "http://test.info/json/movies/1.jpg"
我一直在用这个密码

<?php
include_once 'db_functions.php';
$db = new DB_Functions();
$products = $db->getAllProducts();
$a = array();
$b = array();
$c = 'test.info/json/movies/';
if ($products != false){
    $no_of_users = mysql_num_rows($products);
    while ($row = mysql_fetch_array($products)) {       


        $b["image"] = $c.''.$row["photo"];



        array_push($a,$b);
    }
    echo json_encode($a);
}

请帮我去掉多余的反斜杠。

您可以使用str_replace();或者只是将标志
JSON\u UNESCAPED\u斜杠作为

echo json_encode($a, JSON_UNESCAPED_SLASHES);

您可以使用str_replace();或者只是将标志
JSON\u UNESCAPED\u斜杠作为

echo json_encode($a, JSON_UNESCAPED_SLASHES);

使用选项-
JSON\u UNESCAPED\u斜杠(整数)不转义/。从PHP 5.4.0开始提供。
-谢谢您,它工作了:)这是我的解决方案。echo json_encode($a,json_UNESCAPED_斜线);使用选项-
JSON\u UNESCAPED\u斜杠(整数)不转义/。从PHP 5.4.0开始提供。
-谢谢您,它工作了:)这是我的解决方案。echo json_encode($a,json_UNESCAPED_斜线);