php中chr(ascii)和ord(string)函数用法

 更新时间:2016年11月25日 17:31  点击:2064
这两个函数的功能正好相反chr 函数从指定的 ASCII 值返回字符而ord() 函数返回字符串第一个字符的 ASCII 值。明白这些大家就好用此函数了。

先看chr函数

chr() 函数从指定的 ASCII 值返回字符。

chr(ascii)

ascii 参数可以是十进制、八进制或十六进制。通过前置 0 来规定八进制,通过前置 0x 来规定十六进制

例子

 代码如下 复制代码

<?php
echo chr(52);
echo chr(052);
echo chr(0x52);
?>输出:

4
*
R

是不是很神奇,其实也不怪我经常会把一些看不到编码用chr来操作如

 代码如下 复制代码
<?
echo chr(13);
echo chr(32);
?>

大家想想这会输出什么呢,结果是

一个回车,一个空格

下面再来看ord函数

ord() 函数返回字符串第一个字符的 ASCII 值。


从上面来看正好与chr 相反是吧,

语法

 代码如下 复制代码

ord(string)
例子
<?php
echo ord("h");
echo ord("hello");
?>

输出结果:

104
104

好了,现在我们来看一个综合的实例

 

 代码如下 复制代码
<?php
$str1=chr(88);
echo $str1; //返回值为X
$str2=chr(ord(X)+1); //
echo $str2; //返回值为 Y
echo "t";
$str3=ord('S');
echo $str3; //返回值为83
?>

下面有一篇关于php ord 函数与中文乱码解决方法

更多详细内容请查看:http://www.111cn.net/phper/php-function/php-ord.htm

php中通过对某个日期增加或减去几天,得到另外一个日期,我们会用两个实例来说明一个是strtotime与mktime把时间转换成时间戳再处理,有需要的同学看看。

下例:获得2012-5-1号之前一天的日期

 代码如下 复制代码

<?php
//将时间点转换为时间戳
$date = strtotime('2012-5-1');
//输出一天前的日期,在时间戳上减去一天的秒数
echo date('Y-m-d',$date - 1*24*60*60);
?>

输出:2012-4-30

此外,time()函数获得当前日期的时间戳!

再看一个实例

 代码如下 复制代码

<?PHP
$Date_1=”2008-8-15″;//格式也可以是:$Date_1=”2003-6-25 23:29:14″;

$Date_2=”2009-10-1″;

$Date_List_a1=explode(“-”,$Date_1);

$Date_List_a2=explode(“-”,$Date_2);

$d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);

$d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);

$Days=round(($d1-$d2)/3600/24);

Echo “两日期之前相差有$Days 天”;
?>

一些时间参考

 代码如下 复制代码

<?php echo $showtime=date(“Y-m-d H:i:s”);?>

显示的格式: 年-月-日 小时:分钟:妙

相关时间参数:

a – “am” 或是 “pm”
A – “AM” 或是 “PM”
d – 几日,二位数字,若不足二位则前面补零; 如: “01″ 至 “31″
D – 星期几,三个英文字母; 如: “Fri”
F – 月份,英文全名; 如: “January”
h – 12 小时制的小时; 如: “01″ 至 “12″
H – 24 小时制的小时; 如: “00″ 至 “23″
g – 12 小时制的小时,不足二位不补零; 如: “1″ 至 12″
G – 24 小时制的小时,不足二位不补零; 如: “0″ 至 “23″
i – 分钟; 如: “00″ 至 “59″
j – 几日,二位数字,若不足二位不补零; 如: “1″ 至 “31″
l – 星期几,英文全名; 如: “Friday”
m – 月份,二位数字,若不足二位则在前面补零; 如: “01″ 至 “12″
n – 月份,二位数字,若不足二位则不补零; 如: “1″ 至 “12″
M – 月份,三个英文字母; 如: “Jan”
s – 秒; 如: “00″ 至 “59″
S – 字尾加英文序数,二个英文字母; 如: “th”,”nd”
t – 指定月份的天数; 如: “28″ 至 “31″
U – 总秒数
w – 数字型的星期几,如: “0″ (星期日) 至 “6″ (星期六)
Y – 年,四位数字; 如: “1999″
y – 年,二位数字; 如: “99″
z – 一年中的第几天; 如: “0″ 至 “365″

可以自由设定显示的内容,连接符号或是显示位置,例如 date(“m-d H”) 或者date(“dmY”);?>等

文章很简单二个实例实现了php目录创建与递归无限创建和删除目录功能,有需要的朋友可以参考一下,我们用的是mkdir,rddir来实例的。

下面是程序代码:

 代码如下 复制代码
function mkdirs($dir)
{
if(!is_dir($dir))
{
if(!mkdirs(dirname($dir))){
return false;
}
if(!mkdir($dir,0777)){
return false;
}
}
return true;
}
mkdirs('div/css/layout');

同样的思路,php用rmdir和unlink递归删除多级目录的代码:

 代码如下 复制代码

function rmdirs($dir)
{
$d = dir($dir);
while (false !== ($child = $d->read())){
if($child != '.' && $child != '..'){
if(is_dir($dir.'/'.$child))
rmdirs($dir.'/'.$child);
else unlink($dir.'/'.$child);
}
}
$d->close();
rmdir($dir);
}

这是一个最基础的留言板程序了,但是己经有了留言板程序基本功能,很适合于php初学者用用,学习用啊,当然也可以用于企业网站也是很不错的哦。

 

 代码如下 复制代码

<?php
session_start();
$con=mysql_connect('localhost','root','root') or die('链接数据库失败!');
mysql_query('set names utf8');
mysql_select_db('GuestBook');

$pagesize = 10;//每一页显示多少留言记录
if(isset($_GET['page'])&&$_GET['page']!='') $page=$_GET['page'];
else $page=0;

$sql = "SELECT a . * , b.name, b.email, b.qq, c.revert_time, c.revert
  FROM post a
  LEFT JOIN revert c ON ( a.id = c.post_id ) , guest b
  WHERE a.guest_id = b.id
  ORDER BY a.id DESC";
$numRecord = mysql_num_rows(mysql_query($sql));
$totalpage = ceil($numRecord/$pagesize);

$recordSql = $sql. " LIMIT ".$page*$pagesize.",".$pagesize;
$result = mysql_query($recordSql);
?>
<!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=utf-8" />
<title>PHPiask简易留言板</title>
<style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
}
a:link {
 text-decoration: none;
 color: #FF6600;
}
a:visited {
 text-decoration: none;
}
a:hover {
 text-decoration: underline;
}
a:active {
 text-decoration: none;
}
.STYLE1 {
 color: #FFFFFF;
 font-weight: bold;
 font-size: 16px;
}
td{
font-size:12px;
}
.tdhx {
 font-style: italic;
 line-height: 1.5;
 text-decoration: underline;
}
-->
</style>
<script language="javascript">
function checkInput(){
 var Email = document.getElementById('email');
 var QQ = document.getElementById('qq');
 var name = document.getElementById('name');
 var post = document.getElementById('post');
 //验证用户名:不能超过10个字符(5个汉字),不能输入非法字符,不能为空
 nameValue = name.value.replace(/s+/g,"");
 var SPECIAL_STR = "~!%^&*();"?><[]{}\|,:/=+—";
 var nameflag=true;
 for(i=0;i<nameValue.lenght;i++){
  if (SPECIAL_STR.indexOf(nameValue.charAt(i)) !=-1)
  nameflag=false;
 }
 if(nameValue==''){
  alert('请填写用户名称!'); 
  return false;
 }
 if(nameValue.length>10){
  alert('用户名称最多10个字符(5个汉字)!');
  return false;
 }
 
 if(nameflag===false){
  alert('用户名称不能包含非法字符请更改!');
  return false;
 }
 //验证QQ号码
 var par =/^[1-9]d{4,12}$/;
 if(QQ.value!=''&&!par.test(QQ.value)){
  alert('请输入正确的QQ号码');
  return false;
 }
 //验证Email地址
 var emailpar = /^[w-]+(.[w-]+)*@[w-]+(.[w-]+)+$/;
 if(Email.value!=''&&!emailpar.test(Email.value)){
  alert('请输入正确的邮箱地址!');
  return false;
 }
 if(QQ.value==''&&Email.value==''){
  alert('邮箱和QQ必选其一');
  return false;  
 }
 if(post.value==""){
  alert('请输入留言内容!');
  return false;   
 }
 if(post.value.length>400){
  alert('留言内容太长!');
  return false;   
 }

}
</script>
</head>

<body>
<table width="800" border="0" align="center">

  <tr>
    <td height="80" bgcolor="#003366"><span class="STYLE1"> 简易留言板教程(<a href="http://www.phpiask.com">PHP iask</a>)</span></td>
  </tr>
  <tr>
    <td height="5" bgcolor="#efefef"></td>
  </tr>
</table>
<table width="800" border="0" align="center" bgcolor="#fefefe">
<?php
while($rs=mysql_fetch_object($result)){
?>
  <tr>
    <td class="tdhx">留言人:<?php echo $rs->name?> |Email:<?php echo $rs->email?>|QQ:<?php echo $rs->qq?>|留言时间:<?php echo date("Y-m-d H:i:s",$rs->post_time+8*3600)?></td>
  </tr>
  <?php
  if(isset($_SESSION['login'])&&$_SESSION['login']){
  ?>
    <tr>
    <td class="tdhx"><a href="revert.php?id=<?php echo $rs->id?>">回复</a> | <a href="delete.php?id=<?php echo $rs->id?>">删除</a></td>
  </tr>
  <?php
  }
  ?>
  <tr>
    <td>留言内容:<?php echo nl2br(htmlspecialchars($rs->post))?><br/>
    <font color="Red">
    回复内容:<?php echo nl2br(htmlspecialchars($rs->revert))?>[<?php if($rs->revert_time!="") echo date("Y-m-d H:i:s",$rs->revert_time+8*3600)?> ]
    </font>
   
    </td>
  </tr>
  <tr><td height="3px"  bgcolor="##FF6600"></td></tr>
<?php
}
?>
</table>
<table width="800" border="0" align="center" bgcolor="#B1C3D9">
  <tr>
    <td >
<?php
if($page>0) echo "<a href='index.php?page=".($page-1)."'>上一页|</a>" ;
if($page<$totalpage-1) echo "<a href='index.php?page=".($page+1)."'>下一页</a>" ;
?></td>
  </tr>
</table><form action="post.php" method="post" id="postForm" name="postForm">
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#efefef">
 
  <tr>
    <td width="117" bgcolor="#FFFFFF">姓名:</td>
    <td width="673" bgcolor="#FFFFFF"><label>
      <input type="text" name="name" id="name" />
    </label></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">Email:</td>
    <td bgcolor="#FFFFFF"><label>
      <input type="text" name="email" id="email" />
    </label></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">QQ:</td>
    <td bgcolor="#FFFFFF"><label>
      <input type="text" name="qq" id="qq"/>
    </label></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#FFFFFF">留言内容:</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#FFFFFF"><label>
      <textarea name="post" id="post" cols="40" rows="5"></textarea>
    </label></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#FFFFFF"><label>
      <input type="submit" name="Submit" value="提交" onclick="return checkInput();"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input type="reset" name="Submit2" value="重置" />
    </label><a href="login.php">管理员登录</a></td>
  </tr>
</table></form>
</body>
</html>

post.php文件

<?php
header('content-type:text/html;charset=utf-8');
//如果PHP设置的自动转义函数未开启,就转义这些值
if(!get_magic_quotes_gpc()){
 foreach ($_POST as &$items){
  $items = addslashes($items);
 }
}

$name = $_POST['name'];
$qq = $_POST['qq'];
$email = $_POST['email'];
$post = $_POST['post'];

if($name==""||strlen($name)>10){
 echo <<<tem
 <script language="javascript">
 alert('请输入正确的有户名');
 history.go(-1);
 </script>
tem;
exit();
}
if($qq==""&&$email==""){
 echo <<<tem
 <script>
 alert('Email和QQ必须输入一个!');
 history.go(-1);
 </script>
tem;
exit();
}
if($qq!=""&&(!is_numeric($qq)||$qq>9999999999||$qq<=9999)){
 echo <<<tem
 <script>
 alert("请输入正确的QQ号码");
 history.go(-1);
 </script>
tem;
exit();
}
if($email!=""&&(!ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+",$email)||strlen($email)>60)){
 echo <<<tem
 <script>
 alert("请输入正确的Email");
 history.go(-1);
 </script>
tem;
exit();
}
if(strlen($post)>400){
 echo <<<tem
 <script>
 alert("输入的留言内容太长!");
 history.go(-1);
 </script>
tem;
exit();
}

//链接数据库
$con=mysql_connect('localhost','root','root') or die('链接数据库失败!');
mysql_query('set names utf8');
mysql_select_db('GuestBook');

//把客户信息插入guest表
$insertSql="insert into guest (name,qq,email) values ('$name','$qq','$email')";
if(mysql_query($insertSql)){
 $guestid = mysql_insert_id();
}
else{
 echo $insertSql;
 echo mysql_error();
 echo "数据插入失败!";
 exit();
}

//把以上插入取得的客户id和留言信息插入到post表中
$post_time = time();
$insertPostSql = "insert into post(guest_id,post,post_time) values('$guestid','$post','$post_time')";
if(mysql_query($insertPostSql)){
 echo <<<tem
 <script>
 alert("留言成功");
 location.href="index.php";
 </script>
tem;
}
else{
 echo <<<tem
 <script>
 alert("留言失败");
 location.href="index.php";
 </script>
tem;
}
?>

下面为后台管理管理的页面 login.php登录先

 

 代码如下 复制代码
<?php
session_start();
if(isset($_POST['Submit'])){
 if(!get_magic_quotes_gpc()){
  foreach ($_POST as &$items){
   $items = addslashes($items);
  }
 }
 if($_POST['username']=='phpiask'&&md5($_POST['password'])=='6dc88b87062a5de19895e952fa290dad'){
  $_SESSION['login']=true;
  echo "<script>alert('管理员登录成功');location.href='index.php';</script>";
  exit();
 }
 else {
  echo "<script>alert('登录失败!');</script>";
 }
}
?>
<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<table>
<tr>
<td>
<form action="login.php" method="POST" name="form1">
用户名:<input type="text" name="username" size="20"/>
密码:<input type="password" name="password" size="20">
<input type="submit" value="登录" name="Submit"/>
<input type="button" onclick="javascript:location.href='index.php'" value="放弃"/>
</form>
</td>
</tr>
</table>
</body>
</html>

删除留言的delete.php

 代码如下 复制代码

<?php
session_start();
header('content-type:text/html;charset=utf-8');
$con=mysql_connect('localhost','root','root') or die('链接数据库失败!');
mysql_query('set names utf8');
mysql_select_db('GuestBook');

if(!$_SESSION['login']){
 echo "<script>alert('权限不足!');location.href='index.php';</script>";
 exit();
}

if(isset($_GET['id'])&&$_GET['id']!=""){
 $delRevertSql="delete from revert where post_id=".$_GET['id'];
 mysql_query($delRevertSql);
 
 $delGuestSql="delete from guest where id = (select guest_id from post where id=".$_GET['id'].")";
 mysql_query($delGuestSql);
 
 $delPostSql="delete from post where id=".$_GET['id'];
 mysql_query($delPostSql);
 
 if(mysql_error()==""){
  echo "<script>alert('删除成功!');location.href='index.php';</script>";
 }
}
?>

回复留言的revert.php文件

 代码如下 复制代码

<?php
session_start();
$con=mysql_connect('localhost','root','root') or die('链接数据库失败!');
mysql_query('set names utf8');
mysql_select_db('GuestBook');

if(!$_SESSION['login']){
 echo "<script>alert('没有登录不能回复!');location.href='index.php';</script>";
 exit();
}
if($_POST['Submit']){
 if(!get_magic_quotes_gpc()){
  foreach ($_POST as $items){
   $items = addslashes($items);
  }
 }
 if(strlen($_POST['revert'])>400){
  echo "<script>alert('回复内容过长!');history.go(-1);</script>";
  exit();
 }
 $post_id = $_POST['post_id'];
 $revert = $_POST['revert'];
 $insertRevertSql = "insert into revert (post_id,revert,revert_time) value('$post_id','$revert','$time')";
 if(mysql_query($insertRevertSql)){
  echo "<script>alert('回复成功');location.href='index.php';</script>";
  exit();
 }
 else {
  echo "<script>alert('回复失败!');history.go(-1);</script>";
 }
}
?>
<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<table>
<tr>
<td>
<form action="revert.php" method="POST" name="form1">
回复内容:<textarea name="revert" cols="30" rows="5" id="revert"></textarea>
<input type="hidden" name="post_id" value="<?php echo $_GET['id']?> "size="20">
<input type="submit" value="回 复" name="Submit"/>
<input type="button" onclick="javascript:history.go(-1);" value="放弃"/>
</form>
</td>
</tr>
</table>
</body>
</html>

以前我们开发大型项目时都会用到svn来同步,因为开发产品的人过多,所以我们会利用软件来管理,今天发有一居然可以利用php来管理svn哦,好了看看吧。
 代码如下 复制代码

<?php
/**
*
* This class for execute the external program of svn
*
* @auth Seven Yang http://www.111cn.net
*
*/
class SvnPeer
{
/**
* List directory entries in the repository
*
* @param string a specific project repository path
* @return bool true, if validated successfully, otherwise false
*/
static public function ls($repository)
{
$command = "svn ls " . $repository;
$output = SvnPeer::runCmd($command);
$output = implode("<br>", $output);
if (strpos($output, 'non-existent in that revision')) {
return false;
}
return "<br>" . $command . "<br>" . $output;
}
/**
* Duplicate something in working copy or repository, remembering history
*
* @param $src
* @param $dst
* @param $comment string specify log message
* @return bool true, if copy successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function copy($src, $dst, $comment)
{
$command = "svn cp $src $dst -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode("<br>", $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "<br>" . $command . "<br>" . $output;
}
/**
* Remove files and directories from version control
*
* @param $url
* @return bool true, if delete successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function delete($url, $comment)
{
$command = "svn del $url -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode('<br>', $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "<br>" . $command . "<br>" . $output;
}
/**
* Move and/or rename something in working copy or repository
*
* @param $src string trunk path
* @param $dst string new branch path
* @param $comment string specify log message
* @return bool true, if move successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function move($src, $dst, $comment)
{
$command = "svn mv $src $dst -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode('<br>', $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "<br>" . $command . "<br>" . $output;
}
/**
* Create a new directory under version control
*
* @param $url string
* @param $comment string the svn message
* @return bool true, if create successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function mkdir($url, $comment)
{
$command = "svn mkdir $url -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode('<br>', $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "<br>" . $command . "<br>" . $output;
}
static public function diff($pathA, $pathB)
{
$output = SvnPeer::runCmd("svn diff $pathA $pathB");
return implode('<br>', $output);
}
static public function checkout($url, $dir)
{
$command = "cd $dir && svn co $url";
$output = SvnPeer::runCmd($command);
$output = implode('<br>', $output);
if (strstr($output, 'Checked out revision')) {
return true;
}
return "<br>" . $command . "<br>" . $output;
}
static public function update($path)
{
$command = "cd $path && svn up";
$output = SvnPeer::runCmd($command);
$output = implode('<br>', $output);
preg_match_all("/[0-9]+/", $output, $ret);
if (!$ret[0][0]){
return "<br>" . $command . "<br>" . $output;
}
return $ret[0][0];
}
static public function merge($revision, $url, $dir)
{
$command = "cd $dir && svn merge -r1:$revision $url";
$output = implode('<br>', SvnPeer::runCmd($command));
if (strstr($output, 'Text conflicts')) {
return 'Command: ' . $command .'<br>'. $output;
}
return true;
}
static public function commit($dir, $comment)
{
$command = "cd $dir && svn commit -m'$comment'";
$output = implode('<br>', SvnPeer::runCmd($command));
if (strpos($output, 'Committed revision') || empty($output)) {
return true;
}
return $output;
}
static public function getStatus($dir)
{
$command = "cd $dir && svn st";
return SvnPeer::runCmd($command);
}
static public function hasConflict($dir)
{
$output = SvnPeer::getStatus($dir);
foreach ($output as $line){
if ('C' == substr(trim($line), 0, 1) || ('!' == substr(trim($line), 0, 1))){
return true;
}
}
return false;
}
/**
* Show the log messages for a set of path with XML
*
* @param path string
* @return log message string
*/
static public function getLog($path)
{
$command = "svn log $path --xml";
$output = SvnPeer::runCmd($command);
return implode('', $output);
}
static public function getPathRevision($path)
{
$command = "svn info $path --xml";
$output = SvnPeer::runCmd($command);
$string = implode('', $output);
$xml = new SimpleXMLElement($string);
foreach ($xml->entry[0]->attributes() as $key=>$value){
if ('revision' == $key) {
return $value;
}
}
}
static public function getHeadRevision($path)
{
$command = "cd $path && svn up";
$output = SvnPeer::runCmd($command);
$output = implode('<br>', $output);
preg_match_all("/[0-9]+/", $output, $ret);
if (!$ret[0][0]){
return "<br>" . $command . "<br>" . $output;
}
return $ret[0][0];
}
/**
* Run a cmd and return result
*
* @param string command line
* @param boolen true need add the svn authentication
* @return array the contents of the output that svn execute
*/
static protected function runCmd($command)
{
$authCommand = ' --username ' . SVN_USERNAME . ' --password ' . SVN_PASSWORD . ' --no-auth-cache --non-interactive --config-dir '.SVN_CONFIG_DIR.'.subversion';
exec($command . $authCommand . " 2>&1", $output);
return $output;
}
}
[!--infotagslink--]

相关文章

  • php正确禁用eval函数与误区介绍

    eval函数在php中是一个函数并不是系统组件函数,我们在php.ini中的disable_functions是无法禁止它的,因这他不是一个php_function哦。 eval()针对php安全来说具有很...2016-11-25
  • php中eval()函数操作数组的方法

    在php中eval是一个函数并且不能直接禁用了,但eval函数又相当的危险了经常会出现一些问题了,今天我们就一起来看看eval函数对数组的操作 例子, <?php $data="array...2016-11-25
  • Python astype(np.float)函数使用方法解析

    这篇文章主要介绍了Python astype(np.float)函数使用方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-06-08
  • Python中的imread()函数用法说明

    这篇文章主要介绍了Python中的imread()函数用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-16
  • 详解C++ string常用截取字符串方法

    这篇文章主要介绍了C++ string常用截取字符串方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-04-25
  • C# 中如何取绝对值函数

    本文主要介绍了C# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧...2020-06-25
  • C#学习笔记- 随机函数Random()的用法详解

    下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • C#中using的三种用法

    using 指令有两个用途: 允许在命名空间中使用类型,以便您不必限定在该命名空间中使用的类型。 为命名空间创建别名。 using 关键字还用来创建 using 语句 定义一个范围,将在此...2020-06-25
  • mybatis 返回Integer,Double,String等类型的数据操作

    这篇文章主要介绍了mybatis 返回Integer,Double,String等类型的数据操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-25
  • 金额阿拉伯数字转换为中文的自定义函数

    CREATE FUNCTION ChangeBigSmall (@ChangeMoney money) RETURNS VarChar(100) AS BEGIN Declare @String1 char(20) Declare @String2 char...2016-11-25
  • Android开发中findViewById()函数用法与简化

    findViewById方法在android开发中是获取页面控件的值了,有没有发现我们一个页面控件多了会反复研究写findViewById呢,下面我们一起来看它的简化方法。 Android中Fin...2016-09-20
  • C++中 Sort函数详细解析

    这篇文章主要介绍了C++中Sort函数详细解析,sort函数是algorithm库下的一个函数,sort函数是不稳定的,即大小相同的元素在排序后相对顺序可能发生改变...2022-08-18
  • PHP用strstr()函数阻止垃圾评论(通过判断a标记)

    strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。语法:strstr(string,search)参数string,必需。规定被搜索的字符串。 参数sea...2013-10-04
  • PHP函数分享之curl方式取得数据、模拟登陆、POST数据

    废话不多说直接上代码复制代码 代码如下:/********************** curl 系列 ***********************///直接通过curl方式取得数据(包含POST、HEADER等)/* * $url: 如果非数组,则为http;如是数组,则为https * $header:...2014-06-07
  • php中的foreach函数的2种用法

    Foreach 函数(PHP4/PHP5)foreach 语法结构提供了遍历数组的简单方式。foreach 仅能够应用于数组和对象,如果尝试应用于其他数据类型的变量,或者未初始化的变量将发出错误信息。...2013-09-28
  • C语言中free函数的使用详解

    free函数是释放之前某一次malloc函数申请的空间,而且只是释放空间,并不改变指针的值。下面我们就来详细探讨下...2020-04-25
  • PHP函数strip_tags的一个bug浅析

    PHP 函数 strip_tags 提供了从字符串中去除 HTML 和 PHP 标记的功能,该函数尝试返回给定的字符串 str 去除空字符、HTML 和 PHP 标记后的结果。由于 strip_tags() 无法实际验证 HTML,不完整或者破损标签将导致更多的数...2014-05-31
  • SQL Server中row_number函数的常见用法示例详解

    这篇文章主要给大家介绍了关于SQL Server中row_number函数的常见用法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-12-08
  • 浅谈C++中的string 类型占几个字节

    本篇文章小编并不是为大家讲解string类型的用法,而是讲解我个人比较好奇的问题,就是string 类型占几个字节...2020-04-25
  • PHP加密解密函数详解

    分享一个PHP加密解密的函数,此函数实现了对部分变量值的加密的功能。 加密代码如下: /* *功能:对字符串进行加密处理 *参数一:需要加密的内容 *参数二:密钥 */ function passport_encrypt($str,$key){ //加密函数 srand(...2015-10-30