۳۵٪ تخفیف روی تمامی دوره ها🔥 + دوره زبان تخصصی و مهاجرت با ارزش ۵ میلیون تومان بصورت هدیه
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ sajadgheisari
تمرین homework
جامعه پی اچ پی ایجاد شده در ۱۹ اردیبهشت ۱۴۰۳
$array = array('firstname' => 'sajad', 'age'=> 28 , 'from' => 'tehran');
$jsontoencode = json_encode($array);
echo $jsontoencode ;
echo "<hr>";
    if($jsontoencode = true){
        echo 'is json';
    }
    else
    {
        echo 'not json';
    }

سلام،

برای چک کردن شرط از تک مساوی استفاده نکنید چون assignment است و باید == یا === استفاده کنید.

$array = array('firstname' => 'sajad', 'age'=> 28, 'from' => 'tehran');
$jsontoencode = json_encode($array);
echo $jsontoencode;
echo "<hr>";
if ($jsontoencode) {
    echo 'is json';
} else {
    echo 'not json';
}
محسن موحد ۱۹ اردیبهشت ۱۴۰۳، ۱۳:۵۲