passing php variable in onClick function

前端 未结 6 1146
夕颜
夕颜 2020-12-30 07:42

I want to pass the php variable value in onClick function. When i pass the php variable, in the UI i am getting the variable itself instead I need the value in the variable.

6条回答
  •  余生分开走
    2020-12-30 08:40

    $var = "Hello World!";
    echo "$var"; // echoes Hello World!
    echo '$var'; // echoes $var
    

    Don't mix up " and ', they both have importance. If you use some " in your string and don't want to use the same character as delimiter, use this trick:

    echo 'I say "Hello" to ' . $name . '!';
    

提交回复
热议问题