PHP中文函数连载(二)

 更新时间:2016年11月25日 16:12  点击:1342

函数count()
描述:
计算一变量中元素的个数
int count (mixed var);
Returns the number of elements in var , which is typically an array (since anything else will have one element).
Returns 0 if the variable is not set.
Returns 1 if the variable is not an array.

 

函数current()
描述:
传回数组指针目前所指的元素

 

mixed current (array array);

 

Each array variable has an internal pointer that points to one of its elements. In addition, all of the elements in the array are linked by a bidirectional linked list for traversing purposes. The internal pointer points to the first element that was inserted to the array until you run one of the functions that modify that pointer on that array.

 

The current() function simply returns the array element that's currently being pointed by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list, current() returns false.

 

函数each()
描述:
返回数组中下一对key/value的值

 

array each (array array);

 

Returns the current key/value pair from the array array and advances the array cursor. This pair is returned in a four-element array, with the keys 0 , 1 , key , and value . Elements 0 and key each contain the key name of the array element, and 1 and value contain the data.

 

Example 1. each() examples

 

$foo = array( "bob", "fred", "jussi", "jouni" ); $bar = each( $foo );
$bar now contains the following key/value pairs:

 

0 => 0
1 => 'bob'
key => 0
value => 'bob'

 

$foo = array( "Robert" => "Bob", "Seppo" => "Sepi" ); $bar = each( $foo );

 

$bar now contains the following key/value pairs:

 

0 => 'Robert'
1 => 'Bob'
key => 'Robert'
value => 'Bob'

 

Example 2. Traversing $HTTP_POST_VARS with each()

 

echo "Values submitted via POST method:<br>";
while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {
echo "$key => $val<br>";
}

 

函数end()
描述:
将数组中的指针移到最后一个
end (array array);
end() advances array 's internal pointer to the last element.

 

函数key()
描述:
从一数组中取出key
mixed key (array array);
key() returns the index element of the current array position.

 

函数ksort()
描述:
以key来排列一数组
Example 1. ksort() example

 

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
ksort($fruits);
for(reset($fruits);
$key = key($fruits);
next($fruits)) { echo "fruits[$key] = ".$fruits[$key]." "; }

 

This example would display: fruits[a] = orange fruits[b] = banana fruits[c] = apple fruits[d] = lemon

 

函数list()
描述:
用类似数组的方式去指定一整串变量的值
Example 1. list() example

 

<table> <tr> <th> Employee name</th>
<th>Salary</th> </tr>
<?php $result = mysql($conn, "SELECT id, name, salary FROM employees");
while (list($id, $name, $salary) = mysql_fetch_row($result)) {
print(" <tr> "."<td><a href="info.php3?id=$id">$name</a></td> "."<td>$salary</td> "." </tr> ");
}
?>
</table>

 

函数next()
描述:
将数组的指向指到下一组数据

 


函数pos()
描述:
传回数组的当前的数据

 

函数prev()
描述:
传回数组的前一条的数据

 

函数reset()
描述:
数组的指针指到第一条

 

函数rsort ()
描述:
以倒序方式排列一个数组
Example 1. rsort() example

 

$fruits = array("lemon","orange","banana","apple");
rsort($fruits);
for(reset($fruits); ($key,$value) = each($fruits); ) {
echo "fruits[$key] = ".$value." ";
}

 

This example would display: fruits[0] = orange fruits[1] = lemon fruits[2] = banana fruits[3] = apple The fruits have been sorted in reverse alphabetical order.

 

函数sizeof()
描述:
取得一个数组的大小和元素的数目

 

函数sort()
描述:
排序数组
Example 1. sort() example

 

$fruits = array("lemon","orange","banana","apple");
sort($fruits);
for(reset($fruits);
$key = key($fruits);
next($fruits)) {
echo "fruits[$key] = ".$fruits[$key]." ";
}

 

This example would display: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange The fruits have been sorted in alphabetical order.

 

函数uasort()
描述:
以自定义的方式排列一个数组且序列不变。

 


函数uksort()
描述:
以自定义的方式以key排列
This function will sort the keys of an array using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. Example 1. uksort()

记得 HTML 从1.0 版发展到 2.0 版的那些令人兴奋的日子吗,那时把握一种新的 Web 语言就和查看 Web 站点之后的代码一样简单?记得轻松的学习基础 HTML 吗?记得能够随意地构建出一些代码,并在编写时快速地查看外观,而且假如它不能运行,能够轻易地修改 HTML 代码吗?没有 IDE,没有对象和类。只需一个文本编辑器、一些标记和您自己的聪明才智。堪称快速和经济高效!  

  这些日子不会永远消逝。这种“保持简单”的精神在 PHP(近几年来得到广泛应用的一种脚本语言)中继续延续。这种语言在不断发展,并逐渐知道 PHP 能做什么以及不能做什么,并且使 Web 应用程序更加易于构建。

  从默默无闻的新生事物到 Web 上的明星角色   

  就像二十世纪五十年代初涉影坛的好莱坞演员,PHP 真正的开始并不广为人知。有些人认为 PHP 代表“个人主页”。有些人认为 PHP 是其发明者姓名的首字母缩写。实际上,PHP 代表超文本预处理器 (Hypertext Pre Processor),它是由一个名叫 Rasmus Lerdorf 的人在 1994/95 年左右发明的。Lerdorf 提出了 PHP 框架,作为跟踪 Web 站点的访问者如何查看其在线简历的一种方式。他公开发布了最初的超文本预处理器源代码,以帮助其它的 Web 开发人员对在线内容执行类似的操作。   

  当时 Web 开发人员受到 HTML 中提供的表示特性的打击,开始发现这种新的 PHP 脚本语言在构建动态内容的 Web 站点时有多大的好处。PHP 代码可以直接嵌入到 HTML 代码中,而且这种年轻的脚本语言就像 HTML 一样易于把握。   

  对开发人员而言,这意味着可以很快学会 PHP,可以快速构建动态内容的 Web 站点,对代码的修改也可以快速地完成。在开发人员编程时,可以立即查看结果,无需 IDE,也无须困扰于处理用户类型和整数类型以及对象和类

对比起 Cookie,Session 是存储在服务器端的会话,相对安全,并且不像 Cookie 那样有存储长度限制,本文简单介绍 Session 的使用。

  由于 Session 是以文本文件形式存储在服务器端的,所以不怕客户端修改 Session 内容。实际上在服务器端的 Session 文件,PHP 自动修改 Session 文件的权限,只保留了系统读和写权限,而且不能通过 ftp 修改,所以安全得多。

  对于 Cookie 来说,假设我们要验证用户是否登陆,就必须在 Cookie 中保存用户名和密码(可能是 md5 加密后字符串),并在每次请求页面的时候进行验证。如果用户名和密码存储在数据库,每次都要执行一次数据库查询,给数据库造成多余的负担。因为我们并不能只做一次验证。为什么呢?因为客户端 Cookie 中的信息是有可能被修改的。假如你存储 $admin 变量来表示用户是否登陆,$admin 为 true 的时候表示登陆,为 false 的时候表示未登录,在第一次通过验证后将 $admin 等于 true 存储在 Cookie,下次就不用验证了,这样对么?错了,假如有人伪造一个值为 true 的 $admin 变量那不是就立即取的了管理权限么?非常的不安全。

  而 Session 就不同了,Session 是存储在服务器端的,远程用户没办法修改 Session 文件的内容,因此我们可以单纯存储一个 $admin 变量来判断是否登陆,首次验证通过后设置 $admin 值为 true,以后判断该值是否为 true,假如不是,转入登陆界面,这样就可以减少很多数据库操作了。而且可以减少每次为了验证 Cookie 而传递密码的不安全性了(Session 验证只需要传递一次,假如你没有使用 SSL 安全协议的话)。即使密码进行了 md5 加密,也是很容易被截获的。

  当然使用 Session 还有很多优点,比如控制容易,可以按照用户自定义存储等(存储于数据库)。我这里就不多说了。

  Session 在 php.ini 是否需要设置呢?一般不需要的,因为并不是每个人都有修改 php.ini 的权限,默认 Session 的存放路径是服务器的系统临时文件夹,我们可以自定义存放在自己的文件夹里,这个稍后我会介绍。

  开始介绍如何创建 Session。非常简单,真的。

  启动 Session 会话,并创建一个 $admin 变量:

<?php
    
//  启动 Session
    
session_start
();
    
//  声明一个名为 admin 的变量,并赋空值。
    
$_SESSION["admin"] = null
;
?>

  如果你使用了 Seesion,或者该 PHP 文件要调用 Session 变量,那么就必须在调用 Session 之前启动它,使用 session_start() 函数。其它都不需要你设置了,PHP 自动完成 Session 文件的创建。

  执行完这个程序后,我们可以到系统临时文件夹找到这个 Session 文件,一般文件名形如:sess_4c83638b3b0dbf65583181c2f89168ec,后面是 32 位编码后的随机字符串。用编辑器打开它,看一下它的内容:

admin|N;

一般该内容是这样的结构:

变量名|类型:长度:值;

并用分号隔开每个变量。有些是可以省略的,比如长度和类型。

  我们来看一下验证程序,假设数据库存储的是用户名和 md5 加密后的密码:

login.php

<?php

    
//  表单提交后...
    
$posts = $_POST
;
    
//  清除一些空白符号
    
foreach ($posts as $key => $value
)
    {
        
$posts[$key] = trim($value
);
    }
    
$password = md5($posts["password"
]);
    
$username = $posts["username"
];

    
$query = "SELECT `username` FROM `user` WHERE `password` = '$password'"
;
    
//  取得查询结果
    
$userInfo = $DB->getRow($query
);

    if (!empty(
$userInfo
))
    {
        if (
$userInfo["username"] == $username
)
        {
            
//  当验证通过后,启动 Session
            
session_start
();
            
//  注册登陆成功的 admin 变量,并赋值 true
            
$_SESSION["admin"] = true
;
        }
        else
        {
            die(
"用户名密码错误"
);
        }
    }
    else
    {
        die(
"用户名密码错误"
);
    }

?>

  我们在需要用户验证的页面启动 Session,判断是否登陆:

<?php

    
//  防止全局变量造成安全隐患
    
$admin = false
;

    
//  启动会话,这步必不可少
    
session_start
();

    
//  判断是否登陆
    
if (isset($_SESSION["admin"]) && $_SESSION["admin"] === true
)
    {
        echo
"您已经成功登陆"
;
    }
    else
    {
        
//  验证失败,将 $_SESSION["admin"] 置为 false
        
$_SESSION["admin"] = false
;
        die(
"您无权访问"
);
    }

?>

  是不是很简单呢?将 $_SESSION 看成是存储在服务器端的数组即可,我们注册的每一个变量都是数组的键,跟使用数组没有什么分别。

  如果要登出系统怎么办?销毁 Session 即可。

<?php

    session_start
();
    
//  这种方法是将原来注册的某个变量销毁
    
unset($_SESSION["admin"
]);

    
//  这种方法是销毁整个 Session 文件
    
session_destroy
();

?>

  Session 能否像 Cookie 那样设置生存周期呢?有了 Session 是否就完全抛弃 Cookie 呢?我想说,结合 Cookie 来使用 Session 才是最方便的。

  Session 是如何来判断客户端用户的呢?它是通过 Session ID 来判断的,什么是 Session ID,就是那个 Session 文件的文件名,Session ID 是随机生成的,因此能保证唯一性和随机性,确保 Session 的安全。一般如果没有设置 Session 的生存周期,则 Session ID 存储在内存中,关闭浏览器后该 ID 自动注销,重新请求该页面后,重新注册一个 Session ID。

  如果客户端没有禁用 Cookie,则 Cookie 在启动 Session 会话的时候扮演的是存储 Session ID 和 Session 生存期的角色。

  我们来手动设置 Session 的生存期:

<?php 

    session_start(); 
    
//  保存一天
    
$lifeTime = 24 * 3600
;
    
setcookie(session_name(), session_id(), time() + $lifeTime, "/"); 

?>

  其实 Session 还提供了一个函数 session_set_cookie_params(); 来设置 Session 的生存期的,该函数必须在 session_start() 函数调用之前调用:

<?php 

    
//  保存一天
    
$lifeTime = 24 * 3600
;
    
session_set_cookie_params($lifeTime
);
    
session_start
();
    
$_SESSION["admin"] = true
;

?>

 

  如果客户端使用 IE 6.0 , session_set_cookie_params(); 函数设置 Cookie 会有些问题,所以我们还是手动调用 setcookie 函数来创建 cookie。

  假设客户端禁用 Cookie 怎么办?没办法,所有生存周期都是浏览器进程了,只要关闭浏览器,再次请求页面又得重新注册 Session。那么怎么传递 Session ID 呢?通过 URL 或者通过隐藏表单来传递,PHP 会自动将 Session ID 发送到 URL 上,URL 形如:http://www.openphp.cn/index.php?PHPSESSID=bba5b2a240a77e5b44cfa01d49cf9669,其中 URL 中的参数 PHPSESSID 就是 Session ID了,我们可以使用 $_GET 来获取该值,从而实现 Session ID 页面间传递。

<?php 

    
//  保存一天
    
$lifeTime = 24 * 3600
;
    
//  取得当前 Session 名,默认为 PHPSESSID
    
$sessionName = session_name
();
    
//  取得 Session ID
    
$sessionID = $_GET[$sessionName
];
    
//  使用 session_id() 设置获得的 Session ID
    
session_id($sessionID
); 

    
session_set_cookie_params($lifeTime);
    
session_start
();
    
$_SESSION["admin"] = true
;

?>

  对于虚拟主机来说,如果所有用户的 Session 都保存在系统临时文件夹里,将给维护造成困难,而且降低了安全性,我们可以手动设置 Session 文件的保存路径,session_save_path()就提供了这样一个功能。我们可以将 Session 存放目录指向一个不能通过 Web 方式访问的文件夹,当然,该文件夹必须具备可读写属性。

<?php 

    
//  设置一个存放目录
    
$savePath = "./session_save_dir/"
;
    
//  保存一天
    
$lifeTime = 24 * 3600
;
    
session_save_path($savePath
);
    
session_set_cookie_params($lifeTime
);
    
session_start
();
    
$_SESSION["admin"] = true
;

?>

  同 session_set_cookie_params(); 函数一样,session_save_path() 函数也必须在 session_start() 函数调用之前调用。

  我们还可以将数组,对象存储在 Session 中。操作数组和操作一般变量没有什么区别,而保存对象的话,PHP 会自动对对象进行序列化(也叫串行化),然后保存于 Session 中。下面例子说明了这一点:

person.php

<?php
    
class
person
    
{
        var
$age
;
        function
output
() {
            echo
$this->age
;
        }
     
        function
setAge($age
) {
            
$this->age = $age
;
        }
    }
?>

setage.php

<?php

    session_start
();
    require_once
"person.php"
;
    
$person = new person
();
    
$person->setAge(21
);
    
$_SESSION['person'] = $person
;
    echo
"<a href='output'>check here to output age</a>"
;

?>

output.php

<?

    
// 设置回调函数,确保重新构建对象。
    
ini_set('unserialize_callback_func', 'mycallback'
);
    function
mycallback($classname
) {
        include_once
$classname . ".php"
;
    }
    
session_start(); 

    
$person = $_SESSION["person"];
    
//  输出 21
    
$person->output
();

?>

  当我们执行 setage.php 文件的时候,调用了 setage() 方法,设置了年龄为 21,并将该状态序列化后保存在 Session 中(PHP 将自动完成这一转换),当转到 output.php 后,要输出这个值,就必须反序列化刚才保存的对象,又因为在解序列化的时候需要实例化一个未定义类,所以我们定义了以后回调函数,自动包含 person.php 这个类文件,因此对象被重构,并取得当前 age 的值为 21,然后调用 output() 方法输出该值。

  另外,我们还可以使用 session_set_save_handler 函数来自定义 Session 的调用方式。

  认识水平有限,本文难免有错误之处,敬请指正。

1。使用xmlhttp对象,类似于asp中的ActiveXObject对象,其实xmlhttp无非就是get和put的操作,在php里面

get的,直接用file_get_contents/fopen/readfile这些函数就是了

put的,自己写fsockopen发送也行,用NET_Curl也行

(直接用系统函数要简单,通用,耗费资源少)

$xhr = new COM("MSXML2.XMLHTTP");
$xhr->open("GET","http://localhost/xxx.php?id=2",false);
$xhr->send();
echo $xhr->responseText

2。上面说的file_get_contents实现

<?php
$url="http://www.blogjava.net/pts";
echo file_get_contents( $url );
?>

3。上面说的fopen()实现

<?
if ($stream = fopen('http://www.sohu.com', 'r')) {
    // print all the page starting at the offset 10
    echo stream_get_contents($stream, -1, 10);
    fclose($stream);
}

if ($stream = fopen('http://www.sohu.net', 'r')) {
    // print the first 5 bytes
    echo stream_get_contents($stream, 5);
    fclose($stream);
}
?>


<?php
/**
*TTR上传类
*2007-09-22
*[url=http://www.gx3.cn/]http://www.Gx3.cn[/url]
*QQ:252319874
**/

class TTRUpload extends 
Error
{
        const 
filesize=81200000
;
        private 
$uploadpath="uploadfile/"
;
        private 
$savepath=null
;
        private 
$uploadfilename=null;                                
//单个文件为文件名,批量文件为xxxx|xxxx格式,请注意
        
private $ext=array("jpg","gif","png"
);
        private 
$error=null
;
        private 
$file=null
;        
        private 
$uploadtype=null
;
        private 
$filename=null
;
        
        
//构造函数,$type:ONE单个上传 ANY批量上传;
        
public function __construct($file,$type="ONE"
)
        {
                if(
$type!="ONE" && $type!="ANY"
)
                {
                        echo 
"<script language='javascript'>alert('初始化请选择ONE或者ANY')</script>"
;
                        exit;
                }
                
$this->uploadtype=$type
;
                
$this->file=$file
;
        }
        
        private function 
createFileName
()
        {
                return 
$this->filename="TTR_".time().$this->getRandomN(4
);
        }
                
        private function 
getUploadPath
()
        {
                if(
substr($this->uploadpath,-1,1)!="/"

                {
                        
$this->savepath=$this->uploadpath."/".date("Ym"
);
                }else{
                        
$this->savepath=$this->uploadpath.date("Ym"
);
                }
                
$this->savepath=$this->getFolder($this->savepath
);
                return 
true
;
        }
        
        private function 
getFileExt($tempfilename
)
        {
                return 
end(explode(".",$tempfilename
));
        }
        
        private function 
getExt
()
        {
                if(
in_array(strtolower($this->getFileExt($tempfilename)),$this->ext
))
                {
                        return 
true
;
                }else{
                        return 
false
;        
                }
        }
        
        private function 
getFolder($folder
)
        {
                if(!
is_dir($folder
))
                {
                        
mkdir($folder
);
                }
                return 
$folder."/"
;
        }
        
        
        public function 
upload
()
        {
                if(
$this->uploadtype=="ONE"
)
                {
                        

                        if(
$this->getExt($this->file["type"
]))
                        {
                                
                                
parent::errorExt
();
                                
                        }else if(
$this->file["size"]>self::filesize
){
                                
                                
parent::errorFileSize
();
                                
                        }else if(!
$this->getUploadPath
()){
                                
                                
parent::errorUploadPath
();
                                
                        }else{
                                
$filenametemp=$this->createFileName
();
                                
$filename=$this->savepath.$filenametemp.".".$this->getFileExt($this->file["name"
]);
                                if(
move_uploaded_file($this->file["tmp_name"],$filename
))
                                {        
                                        
$this->uploadfilename=$filenametemp
;
                                        
parent::okMoved
();                        
                                        
                                
                                }else{
                                        
parent::errorMoveUpload
();
                                }
                        }
                }else if(
$this->uploadtype=="ANY"
){

                        for(
$i=0;$i<count($this->file);$i
++)
                        {
                        
                                if(
$this->getExt($this->file[$i]["type"
]))
                                {
                                        
parent::errorExt
();
                                        
                                }else if(
$this->file[$i]["size"]>self::filesize
){
                                        
                                        
parent::errorFileSize
();
                                        
                                }else if(!
$this->getUploadPath
()){
                                        
                                        
parent::errorUploadPath
();
                                        
                                }else{
                                        
$filenametemp=$this->createFileName
();
                                        
$filename=$this->savepath.$filenametemp.".".$this->getFileExt($this->file[$i]["name"
]);
                                        if(
move_uploaded_file($this->file[$i]["tmp_name"],$filename
))
                                        {        
                                                
$str.=$filenametemp."|"
;
                                                
                                        }else{
                                                
parent::errorMoveUpload
();
                                        }
                                        
                                }
                                
                        }
                        
$this->uploadfilename=substr($str,0,strlen($str)-1
);        
                        
parent::okMoved
();
                }
        }
        
        public function 
getUploadFileName
()
        {
                return 
$this->uploadfilename
;
        }
        
        public function 
setUploadPath($path
)
        {
                
$this->uploadpath=$path
;
        }
        
        
        private function 
getRandomN($n
)
        {
                if (
$n || $n>10)  return ""
;
        
                
$ary_num= array(0,1,2,3,4,5,6,7,8,9
);
                
$return =""
;
                for (
$i=0;$i<$n;$i
++)
                {
                        
$randn rand(0,9-$i
);
                        
$return .= $ary_num[$randn
];
                        
$ary_num[$randn] = $ary_num[9-$i
];
                }
                return 
$return
;
        }

        
        
        public function 
__destruct
()
        {
                
$this->uploadfilename=null
;
                
$this->uploadtype=null
;
                
$this->file=null
;
                
$this->savepath=null
;
        }
        
}

class 
Error
{
        public static function 
errorFileSize
()
        {
                echo 
"超出最大上传限制"
;
        }
        
        public static function 
errorExt
()
        {
                echo 
"此类文件不允许上传"
;
        }
        
        public static function 
errorUploadPath
()
        {
                echo 
"上传路径不正确"
;
        }
        
        public static function 
errorMoveUpload
()
        {
                echo 
"上传失败"
;
        }
        
        public static function 
okMoved
()
        {
                echo 
"上传成功!"
;
        }
        
        public static function 
okArrayMoved
()
        {
                echo 
"上传成功!"
;
        }
}


实例应用:

 


<?php
require_once("include/upload.class.php"
);
if(
$_POST["button"
])
{
    
//print_r($_FILES);
    //多个上传
    
$upload = new TTRUpload(array($_FILES["file1"],$_FILES["file2"],$_FILES["file3"],$_FILES["file4"]),"ANY"
);

    
//单个上传
    //$upload = new TTRUpload($_FILES["file1"]);
    
$upload->upload
();
    echo 
$upload->getUploadFileName
();
}
?>
<!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>Untitled Document</title>
</head>

<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <input type="file" name="file1" id="file1" />
  <br />
  <input type="file" name="file2" id="file2" />
  <br />
  <input type="file" name="file3" id="file3" />
  <br />
  <input type="file" name="file4" id="file4" />
  <br />
  <input type="submit" name="button" id="button" value="Submit" />
</form>
</body>
</html>

[!--infotagslink--]

相关文章

  • js URLdecode()与urlencode方法支持中文解码

    下面来介绍在js中来利用urlencode对中文编码与接受到数据后利用URLdecode()对编码进行解码,有需要学习的机友可参考参考。 代码如下 复制代码 ...2016-09-20
  • 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# 中如何取绝对值函数

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

    下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • 源码分析系列之json_encode()如何转化一个对象

    这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
  • php中去除文字内容中所有html代码

    PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
  • 金额阿拉伯数字转换为中文的自定义函数

    CREATE FUNCTION ChangeBigSmall (@ChangeMoney money) RETURNS VarChar(100) AS BEGIN Declare @String1 char(20) Declare @String2 char...2016-11-25
  • C++中 Sort函数详细解析

    这篇文章主要介绍了C++中Sort函数详细解析,sort函数是algorithm库下的一个函数,sort函数是不稳定的,即大小相同的元素在排序后相对顺序可能发生改变...2022-08-18
  • Android开发中findViewById()函数用法与简化

    findViewById方法在android开发中是获取页面控件的值了,有没有发现我们一个页面控件多了会反复研究写findViewById呢,下面我们一起来看它的简化方法。 Android中Fin...2016-09-20
  • 关于Mysql中文乱码问题该如何解决(乱码问题完美解决方案)

    最近两天做项目总是被乱码问题困扰着,这不刚把mysql中文乱码问题解决了,下面小编把我的解决方案分享给大家,供大家参考,也方便以后自己查阅。首先:用show variables like “%colla%”;show varables like “%char%”;这两条...2015-11-24
  • PHP用strstr()函数阻止垃圾评论(通过判断a标记)

    strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。该函数返回字符串的其余部分(从匹配点)。如果未找到所搜索的字符串,则返回 false。语法:strstr(string,search)参数string,必需。规定被搜索的字符串。 参数sea...2013-10-04
  • index.php怎么打开?如何打开index.php?

    index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
  • 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#读取中文文件出现乱码的解决方法

    这篇文章主要介绍了C#读取中文文件出现乱码的解决方法,涉及C#中文编码的操作技巧,非常具有实用价值,需要的朋友可以参考下...2020-06-25
  • C语言中free函数的使用详解

    free函数是释放之前某一次malloc函数申请的空间,而且只是释放空间,并不改变指针的值。下面我们就来详细探讨下...2020-04-25
  • Windows服务器MySQL中文乱码的解决方法

    我们自己鼓捣mysql时,总免不了会遇到这个问题:插入中文字符出现乱码,虽然这是运维先给配好的环境,但是在自己机子上玩的时候咧,总得知道个一二吧,不然以后如何优雅的吹牛B。...2015-03-15