【php中数字、字符与对象判断函数用法实例】教程文章相关的互联网学习教程文章

php里array_work用法实例分析_PHP

本文实例讲述了php里array_work用法。分享给大家供大家参考。具体如下:// the test array $array = array(php, arrays, are, cool ); // some variable for testing: $some_var = NEW; // the function that gets called for each entry function format_array_values(&$item, $key, $some_var) {$item = $some_var . ": $item (KEY: $key)"; } // "walk" trough each array item and call the function: // "format_array_val...

php类的扩展和继承用法实例_PHP

本文实例讲述了php类的扩展和继承用法。分享给大家供大家参考。具体如下:<?php class Thread { var $topic; //帖子主题 var $body; //帖子内容 var $date; //帖子发布时间 var $author; //帖子作者 //函数Thread用于初始化变量等 function Thread() { //初始化变量 } //函数Send用于提交新帖子 function Send() { //检测变量的合法性后执行插入操作将变量存储到数据库中 } //函数Edit用于编辑帖子 function Edit() { //检测变量...

Codeigniter的dom类用法实例_PHP

本文实例讲述了Codeigniter的dom类用法。分享给大家供大家参考。具体分析如下: 利用simple_html_dom dom类为CI修改的一个类库,可以像JS一样对HTML元素进行分析,适合与抓取网页时,对网页数据进行的分析。 类库下载地址: http://sourceforge.net/projects/simplehtmldom/ 修改: 把simple_html_dom批量替换为CI_Simple_html_dom。 放置在application\libraries下:function index() { //$this->load->view(welcome_message); $thi...

PHP中的常见魔术方法功能作用及用法实例_PHP

概述 在面向对象编程中,PHP提供了一系列的魔术方法,这些魔术方法为编程提供了很多便利。PHP中的魔术方法通常以__(两个下划线)开始,并且不需要显示的调用而是由某种特定的条件出发。这篇文章简单总结了PHP中提供的魔术方法。 开始之前 在总结PHP的魔术方法之前先来定义两个类,以便后边示例使用:代码如下: <?php class Device {public $name; public $battery; public $data = array(); public $connection; ...

PHP获取文件夹大小函数用法实例_PHP

本文实例讲述了PHP获取文件夹大小函数用法。分享给大家供大家参考。具体如下:<?php// 获取文件夹大小function getDirSize($dir){ $handle = opendir($dir);while (false!==($FolderOrFile = readdir($handle))){ if($FolderOrFile != "." && $FolderOrFile != "..") { if(is_dir("$dir/$FolderOrFile")){ $sizeResult += getDirSize("$dir/$FolderOrFile"); }else{ $sizeResult += filesize("$dir/$FolderOrFile"); }} }closedir(...

php类的定义与继承用法实例_PHP

本文实例讲述了php类的定义与继承用法。分享给大家供大家参考。具体如下:<?php /** class*/class people {public $name;public $age;function __construct($namec,$agec) {$this->name = $namec;$this->age = $agec;}protected function getmessage() {return "姓名:".$this->name.""."年龄:".$this->age;}function __tostring() {return "姓名:".$this->name.""."年龄:".$this->age;}function __destruct() {echo " I am dea...

smarty内部日期函数html_select_date()用法实例分析_PHP

本文实例讲述了smarty内部日期函数html_select_date()的用法。分享给大家供大家参考。具体如下: 主要属性: prefix //string类型 默认前缀名为"Date_" start_year //string类型 默认为当前年份 仍可以用(+/-N)模式表示 如start_year="-10" option就从1998年开始 end_year //string类型 默认同上 可用(+/-N)模式表示 如end_year="+5" option就到2013为止 field_order //string类型 默认MDY 即按月日年的顺序 排...

php抽象类用法实例分析_PHP

本文实例讲述了php抽象类用法。分享给大家供大家参考。具体如下:<?php /** abstract* 抽象类:* 1、至少有一个抽象方法(没有具体实现的方法)* 2、不能被实例化,可以被继承* 3、抽象类可以有子抽象类* 相对于接口:* 1、可以有属性* 2、一个子类只能继承一个抽象类,但是可以实现多个接口* * * */abstract class qian {abstract function getfirst();function gettwo() {echo "I am gettwo";}}abstract class jj extends qian {...

php中动态变量用法实例_PHP

本文实例讲述了php中动态变量用法。分享给大家供大家参考。具体分析如下: 定义的固定变量:$my_pic_1=$row["pic_1"]; $my_pic_2=$row["pic_2"]; $my_pic_3=$row["pic_3"]; $my_pic_4=$row["pic_4"]; $my_pic_5=$row["pic_5"]; $my_pic_6=$row["pic_6"]; $my_pic_7=$row["pic_7"]; $my_pic_8=$row["pic_8"];这里我们用循环语句把每个变量的值全部输出来:<?php for ($i=1;$i<=8;$i++) { echo "$my_pic_".$i; } ?> 这样输出<?php ec...

php中smarty模板条件判断用法实例_PHP

本文实例讲述了php中smarty模板条件判断用法。分享给大家供大家参考。具体实现方法如下: 模板文件test6.html代码:Smarty Test {if $cond == 1} 条件成立 {else} 条件不成立 {/if} php代码:<?php require libs/Smarty.class.php; //包含Smarty类库文件 $smarty = new Smarty; //创建一个新的Smarty对象 $cond = 1; $smarty->assign("cond",$cond); //对模版中的变量赋值 $smarty->display(test6.htm); //显示页面 ...

php中smarty变量修饰用法实例分析_PHP

本文实例讲述了php中smarty变量修饰用法。分享给大家供大家参考。具体实现方法如下: test.php代码:<?php require libs/Smarty.class.php; //包含Smarty类库文件 $smarty = new Smarty; //创建一个新的Smarty对象 $total = 12345; //对$total赋值 $smarty->assign("total",$total); //对模版中的变量赋值 $formatted_total = number_format($total); //格式化$total $smarty->assign("formatted_total",$formatted_total); ...

PHP封装的HttpClient类用法实例_PHP

本文实例讲述了PHP封装的HttpClient类。分享给大家供大家参考。具体分析如下: 这是一段php封装的HttpClient类,可实现GET POST Cookie Session等简单的功能。原来做过,这两天重新修改了一下。<?php /* * Filename: httpclient.php * Created on 2012-12-21 * Created by RobinTang * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ class SinCookie { ...

php常用表单验证类用法实例_PHP

本文实例讲述了php常用表单验证类用法。分享给大家供大家参考。具体如下:<?php /** * 页面作用:常用表单验证类 * 作 者:欣然随风 * QQ:276624915 */ class class_post { //验证是否为指定长度的字母/数字组合 function fun_text1($num1,$num2,$str) {Return (preg_match("/^[a-zA-Z0-9]{".$num1.",".$num2."}$/",$str))?true:false; } //验证是否为指定长度数字 function fun_text2($num1,$num2,$str) {return (preg_match("/^...

php文件压缩之PHPZip类用法实例_PHP

本文实例讲述了php文件压缩之PHPZip类用法。分享给大家供大家参考。具体如下:<?php // // PHPZip v1.2 by Sext (sext@neud.net) // // Makes zip archive // // Based on "Zip file creation class", uses zLib // // class PHPZip { function Zip($dir, $zipfilename) {if (@function_exists(gzcompress)){$curdir = getcwd();if (is_array($dir)){$filelist = $dir;}else{$filelist = $this -> GetFileList($dir);}if ((!empty...

php中Snoopy类用法实例_PHP

本文实例讲述了php中Snoopy类用法。分享给大家供大家参考。具体分析如下: 这里演示了php中如何通过Snoopy抓取网页信息 snoopy类的下载地址:http://sourceforge.net/projects/snoopy//* You need the snoopy.class.php from http://snoopy.sourceforge.net/ */ include("snoopy.class.php"); $snoopy = new Snoopy; // need an proxy?: //$snoopy->proxy_host = "my.proxy.host"; //$snoopy->proxy_port = "8080"; // set browse...