我对这个警告有疑问
注意:未定义的变量:第 35 行 C:\wamp\www\android_connect\cara1.php 中的 T_Person
警告:第 35 行 C:\wamp\www\android_connect\cara1.php 中为 foreach() 提供的参数无效
第 35 行是 foreach($T_Person as $Person)
我不明白哪里错了这是我的php代码:
<!DOCTYPE html>
<html>
<head>
<title>Daftar Buku</title>
<!--Bagian CSS untuk Styling Tabel-->
<style type="text/css">
table, th, td
{
border: 1px solid black;
}
</style>
</head>
<body>
<h3>Daftar Buku Terbaru</h3>
<?php
$Person = new SimpleXMLElement('contoh.xml', null, true);
echo "
<table>
<tr>
<th>First name</th>
<th>middle name</th>
<th>Alias</th>
<th>Gender</th>
<th>City</th>
<th>Person ID</th>
</tr>
";
foreach($T_Person as $Person)
{
echo "
<tr>
<td width='200'>{$Person->First_name}</td>
<td width='200'>{$Person->Middle_Name_Person}</td>
<td width='130'>{$Person->Alias_Person}</td>
<td width='80'>\${$Person->Gender_Person}</td>
<td width='130'>{$Person->CityBirth_Person}</td>
<td width='130'>{$Person['Person ID']}</td>
</tr>
";
}
echo '</table>';
?>
</body>
</html>