在php中,javascript的使用(包含了php變量)

使用codeignation框架:

<?php

 $table_row = '<span style="white-space:nowrap">'.anchor('student/edit/'.$student->id,'edit').' | '.anchor('student/delete/'.$student->id,'delete',"οnclick=\" return confirm('Are you sure want to '+'delete the record for ".addslashes($student->s_name)." ?')\"").'</span>';

?>

1、整體是php,所以用.來連接字符串(因爲太長,且不好控制)

2、confirm是javascript函數,所以連接字符串用+號

3、在javascript中,使用變量要用“”(但使用php變量,需要用.來連接字符串)

4、整體相當於echo "<span ....></span>";



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章