如何在html的双引号内转义PHP?

My code is

 echo '<textarea name="" class="widefat" style="width:100%; height: 100px;" value="<?php ?>"></textarea>';

How can I use php inside the value

Looking forward

Thanks

As @quentin mentioned, you're trying to echo a php tag, which you cannot. To use a variable inside a string, without messing with quotes, I normally use heredoc, i.e.:

<?php
$value = 100;
echo <<< EOF
<textarea name="" class="widefat" style="width:100%; height: 100px;" value="{$value}"></textarea>
EOF;

You can't.

The problem here has nothing to do with the HTML. The problem is because you are trying to echo PHP tags.

PHP either outputs everything (by default) or executes PHP (between <?php and ?>). If you explicitly output with echo then you bypass the parser's search for <?php. You can't nest PHP programs in that way.

Refactor your code instead.

?>
<textarea name="" class="widefat" style="width:100%; height: 100px;">
<?php ... ?>
</textarea>
<?php

NB: Textarea elements don't have a value attribute.

You can do it in following ways,

  echo '<textarea name="" class="widefat" style="width:100%; height: 100px;">'.$value.'</textarea>';

Or

 <textarea name="" class="widefat" style="width:100%; height: 100px;"><?php echo $value; ?></textarea>