passing php variable in onClick function

前端 未结 6 1128
夕颜
夕颜 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:41

    I have been using curly braces lately instead of concatenation. I think it looks better/is more readable, and mostly I find it is easier and less prone to human error - keeping all those quotes straight! You will also need quotes around the contents inside of onClick.

    Instead of this:

    Echo ''. $insert .' ';
    

    Try this:

    Echo '{$insert} ';
    

    As a side note, I usually use double quotes to wrap my echo statement and strictly use single quotes within it. That is just my style though. However you do it, be sure to keep it straight. So my version would look like this:

    echo "{$insert}";
    

提交回复
热议问题