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

来源:互联网 发布:虚拟主机怎么解析域名 编辑:程序博客网 时间:2024/06/06 03:05

使用codeignation框架:

<?php

 $table_row = '<span style="white-space:nowrap">'.anchor('student/edit/'.$student->id,'edit').' | '.anchor('student/delete/'.$student->id,'delete',"onclick=\" 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>";



0 0
原创粉丝点击