passing php variable in onClick function

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

    Variable parsing is only done in double quoted strings. You can use string concatenation or, what I find more readable, printf [docs]:

    printf('%s ', $node, $insert);
    

    The best way would be to not echo HTML at all, but to embed PHP in HTML:

    item(0)->nodeValue;
        $insert = "cubicle" . $node;
    ?>
    
     
        
             

    You have to think less about quotes and debugging your HTML is easier too.

    Note: If $node is representing a number, you don't need quotations marks around the argument.

提交回复
热议问题