Checking the passing data array ( Debugging at the PHP and Javascript )

PHP Page တစ္ခုေရးတဲ႕ အခါ Database ထဲကေန Select ယူလုိက္တဲ႕ Data ေတြကို ဘယ္လုိပါလာသလဲ သိခ်င္သည္႔ အခါ ….
print_r(array_name);  Or echo var_dump(array_name);

အေနနဲ႕ ထုတ္ယူၿကည္႔ရႈႏုိင္ပါသည္ …..

print_r(array_name);  Or echo var_dump(array_name);  ေရးၿပီးသည္႔ အခါ
exit(); ၿဖင္႔ လက္ရွိေနရာမွ ထြက္လွ်င္ က်န္ရွိေသာ အလုပ္မ်ားဆက္မလုပ္ေတာ႔ ဘဲ လက္ရွိ run ေနသည္႔ကုိ ရပ္တန္႔သြားပါလိမ္႔မည္ ..

eg .

<?php
$con=mysqli_connect(“myexample.com”,”william”,”db123″,”my_db”);
// Check connection
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}

$result = mysqli_query($con,”SELECT * FROM Persons”);

echo <table border=’1′>
<
tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>”;

while($row = mysqli_fetch_array($result))
{

 var_dump($row);
echo “<tr>”;
echo “<td>” . $row[‘FirstName’] . “</td>”;
echo “<td>” . $row[‘LastName’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;

mysqli_close($con);
?>

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Javascript  ေရးသည္႔ အခါလည္း  PHP မွသယ္လာေသာ Data မ်ားကို စစ္ၿကည္႔ခ်င္သည္႔ အခါ …..
php မွ server ဆီသို႕သြားၿပီး သယ္ယူလာလည္႔ data မ်ားကို  json format အေနနဲ႔ေၿပာင္းၿပီး  alert(data1.join(“\n”)); အေနနဲ႕ ထုတ္ယူၿကည္႔ရႈႏုိင္ပါသည္

var data1 = <?php echo json_encode(test()); ?>;
 alert(data1.join(‘\n’));

<?php function test()
{
return $arrData;
}
?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s