[php]how to confirm deleting without using form.
<html>
<head>
<script type="text/javascript">
<!--
function confirmDelete()
{
return confirm("Are you sure you wish to delete this entry?");
}
//-->
</script>
</head>
<body>
<% $var1 = 2;%>
<a href="?action=delete&id=<?=$var1?>" onclick="return confirmDelete();">
Delete this entry
</a>
</body>
</html>
B
TW:
Line 14 is using PHP's short_open_tag which is not recommended, the formal tag should be <%php %>
Line 15 is using ASP-style <% %> tags.
Of couse you can use the PHP formal tag, the above code is simply to demostrate the other two tags.
To enable short_open_tag and "<?" support in php, you need to modify php.ini, make sure enable below two attributes.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = On
; Allow ASP-style <% %> tags.
; http://php.net/asp-tags
asp_tags = On
相关文档:
函数原型:mixed str_replace(mixed needle,mixed new_needle,mixed haystack[,int &count]);
needle:要被替换的字符串,new_needle:替换用的字符串,haystack:操作字符串,count:替换次数【可选参数】
我们重点试验前三个在使用数组是的执行方式:
&n ......
用户定义的类,也是学好 PHP 所必备的条件之一。而 PHP 的类,和其它的面向对象语言比较起来,还算蛮单纯的。PHP 只有类别 (class)、方法 (method)、属性、以及单一继承 (extensions) 等。对不习惯使用 C++、Java、Delphi 等面向对象语言来开发程序的用户,不妨先阅读一下有关面向对象概念的书,相信可以带来许多的收获。
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</ ......
<?php
//声明数组变量
$arr = array(val1 =>'张三',val2 => '李四',val3 => '王五',val4 => '李明',val5 => '周燕妮');
//foreach循环遍历数组
foreach($arr as $key => $value){
//注意“$value”后必须要一个空格,否则输 ......
<?php
//获得系统时间函数(注意参数中大写Y代表完整年份,小写y代表年份简写)
$sum = date("Y-m-d");
$sum1 = date("y-m-d");
echo "$sum<br/>";
echo "$sum1<br/>";
//md5加密函数
$pass = md5("张三");
......