For example, I have a page where php and html are mixed together, and a variable is stored in the php part:
$class = "active";
In HTML I want to use this variable in the attribute of an element:
<p class="">helloworld</p>
For example, here I want to make the value of class
of this p
be active
, which is just stored in the $class
variable in php String.
what should I do then? Does JavaScript need to be used?
This is implemented in the PHP stage. It is impossible for the JavaScript code to read the value of the PHP variable.