简体   繁体   中英

Echoing an abstract variable in PHP

So I have some code that looks like this

<tr>
 <td>
  <?php echo "text_". $textnum ?>
 </td>
</tr>   

And I want the code to function the same as

<tr>
 <td>
  <?php echo $text_x ?>
 </td>
</tr>  

Where X is the value of $textnum. I cannot just use <?php echo $text_1?> because I dont know which text variable i am going to be echoing

Use <?=${'text_'.$textnum};?> or <?php echo ${'text_'.$textnum}?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM