<header class='panel-title'> <div class='text-center'> <strong>$result[0]->first_name $result[0]->last_name</strong> </div> </header> 

This html code is in echo, how can you correctly display the variable that is $ result?

    3 answers 3

      <?php echo "<header class='panel-title'> <div class='text-center'> <strong>".$result[0]->first_name ." ". $result[0]->last_name."</strong> </div> </header>" ?> 
    • Parse error: syntax error, unexpected '$result' (T_VARIABLE), expecting '}' in D:\OSPanel\domains\localhost\index.php on line 93 - K-9 Parse error: syntax error, unexpected '$result' (T_VARIABLE), expecting '}' in D:\OSPanel\domains\localhost\index.php on line 93
    • corrected his answer - madfan41k
    • one
      thanks a lot - K-9

    well, or even as a more readable option, so you don’t get confused in ." and similar structures:

     <?php echo "<header class='panel-title'> <div class='text-center'> <strong>{$result[0]->first_name} {$result[0]->last_name}</strong> </div> </header>"; ?> 
       <header class='panel-title'> <div class='text-center'> <strong><?php echo $result[0]->first_name ." ". $result[0]->last_name; ?></strong> </div> </header> 
      • This code is already in echo exactly html. and when you enter your code, the syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in - K-9
      • @ Mikhail, I understand in the fields most likely there are such quotes ', then in place.' '., need to ." ". - Bert