簡體   English   中英

PHP數組在HTML頁面中顯示為純文本

[英]PHP array diplaying as plain text in HTML page

我的IIS站點上有PHP和HTML文件,正在嘗試獲取同一頁面上顯示的表單的輸出。 我遇到的問題是加載HTML頁面時,我看到數組信息在該頁面上顯示為純文本。 我已定義表單操作=“”。 另外,當我定義了form action =“ file.php”時,我得到了期望的結果,但是在新的頁面上。 我看了一下這里的鏈接但似乎沒有提供我想要的內容。 我嘗試在每行上添加標簽,這有所幫助,但仍將數組視為純文本。 這是我所擁有的:

<form action="" method = "POST">
MAC Address of phone: <input type="text" name="phonemac"><br><br>
<input type="submit" value="Check Phone Status">
</form>

<?php

$host = "server.com";
$username = "*****";
$password = "*****";

$context = 
stream_context_create(array('ssl'=>array('allow_self_signed'=>true)));

$client = new SoapClient("C:\inetpub\wwwroot\PhoneSetup\AXLAPI.wsdl",
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".$host.":8443/axl",
'login'=>$username,
'password'=>$password,
'stream_context'=>$context

));

$response = $client->getPhone(array("name"=>"$_POST[phonemac]"));
$array = json_decode(json_encode($response), true);

echo $array['return']['phone']['description'];echo '<br><br>';
echo $array['return']['phone']['name']; echo;
?>

</body>
</html>

這個

$myArray = json_decode($data, true);
echo $myArray[0]['id']; // Fetches the first ID
echo $myArray[0]['c_name']; // Fetches the first c_name
// ...

我會用你的代碼寫一個例子

$array = json_decode(json_encode($response), true);

echo $array[0]['phone']
echo $array[0]['description'];
echo '</br></br>';
echo $array[0]['phone'];
echo $array[0]['name']; 

你的代碼就像

<form action="" method = "POST">
MAC Address of phone: <input type="text" name="phonemac"><br><br>
<input type="submit" value="Check Phone Status">
</form>

<?php

$host = "server.com";
$username = "*****";
$password = "*****";

$context = 
stream_context_create(array('ssl'=>array('allow_self_signed'=>true)));

$client = new SoapClient("C:\inetpub\wwwroot\PhoneSetup\AXLAPI.wsdl",
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".$host.":8443/axl",
'login'=>$username,
'password'=>$password,
'stream_context'=>$context

));

$response = $client->getPhone(array("name"=>"$_POST[phonemac]"));
$array = json_decode(json_encode($response), true);


    echo $array[0]['phone']
    echo $array[0]['description'];
    echo '</br></br>';
    echo $array[0]['phone'];
    echo $array[0]['name']; 
    ?>
<body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM