【在特定时间后执行PHP代码】教程文章相关的互联网学习教程文章

通过curl登录访问的PHP代码

$data='username=zjzhoufy@126.com&password=1q2w3e&remember=1';$curlobj = curl_init(); // 初始化curl_setopt($curlobj, CURLOPT_URL, "http://www.imooc.com/user/login"); // 设置访问网页的URLcurl_setopt($curlobj, CURLOPT_RETURNTRANSFER, true); // 执行之后不直接打印出来// Cookie相关设置,这部分设置需要在所有会话开始之前设置date_default_timezone_set('PRC'); // 使用Cookie时,必须先设置时区curl_setopt(...

利用imagick库把PDF转成PNG格式的PHP代码

function pdf2png($PDF,$Path){ if(!extension_loaded(imagick)){ return false; } if(!file_exists($PDF)){ return false; } $IM = new imagick(); $IM->setResolution(120,120); $IM->setCompressionQuality(100); $IM->readImage($PDF); foreach ($IM as $Key => $Var){ $Var->setImageFormat(png); $Filename = $Path./.md5($Key.time())..png; if($Var->writeImage($Filenam...

备份mysql数据的php代码

<?php##################### //CONFIGURATIONS #####################// Define the name of the backup directorydefine(BACKUP_DIR, ./myBackups ) ; // Define Database Credentialsdefine(HOST, localhost ) ; define(USER, testd!b ) ; define(PASSWORD, k^$2y4n9@#VV ) ; define(DB_NAME, test123 ) ; /*Define the filename for the sql fileIf you plan to upload the file to Amazons S3 service , use only lower-cas...

计算文件大小的php代码

function dirSize($directoty){ $dir_size=0; if($dir_handle=@opendir($directoty)) { while($filename=readdir($dir_handle)){ $subFile=$directoty.DIRECTORY_SEPARATOR.$filename; if($filename=='.'||$filename=='..'){ continue; }elseif (is_dir($subFile)) { $dir_size+=dirSize($su...

将linux运行时间格式成易读格式的php代码

$exec = shell_exec('uptime'); $uptime = explode(' up ', $exec); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0], 'day')) { $time = explode(':', $uptime[1]); echo('Current system uptime is ' . $uptime[0]. ', ' . $time[0] . ' hours, ' . $time[1] . ' minutes'); } elseif (strpos($uptime[0], ':')) { $time = explode(':', $uptime[0]); echo('Current system...

将数据以图片的形式输出的PHP代码

$query="select count(ip) as count_ip from tb_count04 ";//查询数据库中总的IP访问量$result=mysql_query($query);$countes=mysql_result($result,0,'count_ip'); //通过GD2函数创建画布$im=imagecreate(240,24);$gray=imagecolorallocate($im,200,200,200);$color =imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255)); //定义字体颜色//输出中文字符$text=iconv("gb2312","utf-8","统计IP的数量:");//对指定的中...

在PHP代码中发送邮件的简单示例

<?phpinclude("class.phpmailer.php");$mail = new PHPMailer();$mail->From = your email address@.com;$mail->FromName = HTML Blog;$mail->Host = host name;$mail->Mailer = smtp;$mail->Subject = subject;$mail->IsHTML(true);$body = HelloHow are you ?;$textBody = Hello, how are you ?;$mail->Body = $body;$mail->AltBody = $textBody;$mail->AddAddress(reciepents full email address);if(!$mail->Send()) echo T...

MongoDB数据库常用操作PHP代码

$conn = new Mongo();//可以简写为//$conn=new Mongo(); #连接本地主机,默认端口.//$conn=new Mongo(“172.21.15.69″); #连接远程主机//$conn=new Mongo(“xiaocai.loc:10086″); #连接指定端口远程主机//$conn=new Mongo(“xiaocai.loc”,array(“replicaSet”=>true)); #负载均衡//$conn=new Mongo(“xiaocai.loc”,array(“persist”=>”t”)); #持久连接//$conn=new Mongo(“mongodb://sa:123@localhost”); #带用户名密码#选...

php代码备份mysql数据库

$Database_name = 'somedb';$table = 'sometable'; Define ('H', 'localhost'); define ('N', 'root') define ('P','password'); define ('T', $database_name); Mysql_connect (H, N, P) or die (mysql_error ()); mysql_select_db (T) or die (mysql_error ()); function Escape($v){return mysql_real_escape_string($v);} Define('FILE', 'C:/Program Files/EasyPHP 2.0b1/www/'. $table .'/'. date ('d').'-'...

将图片转成base64字符串的PHP代码

此代码将帮助你学习如何将图像转换成一个base64字符串。 Image to Base64 String Image to Base64 String 转成, PHP

将颜色转换为其反色的PHP代码

这段php代码可以把一个颜色变成与之相反的颜色编码,如:白色变成黑色,蓝色变成黄色 function color_inverse($color){ $color = str_replace(#, , $color); if (strlen($color) != 6){ return 000000; } $rgb = ; for ($x=0;$x<3;$x++){ $c = 255 - hexdec(substr($color,(2*$x),2)); $c = ($c < 0) ? 0 : dechex($c); $rgb .= (strlen($c) < 2) ? 0.$c : $c; } return #.$rgb;}//使用范...

获取内存使用信息的PHP代码

使用这个php代码,你就可以知道你服务器上使用RAM(内存)的情况。echo "Initial: ".memory_get_usage()." bytes \n";/* printsInitial: 361400 bytes*/// lets use up some memoryfor ($i = 0; $i < 100000; $i++) { $array []= md5($i);}// lets remove half of the arrayfor ($i = 0; $i < 100000; $i++) { unset($array[$i]);}echo "Final: ".memory_get_usage()." bytes \n";/* printsFinal: 885912 bytes*/echo "Peak: ".mem...

遍历某文件夹下的所有文件和文件夹php代码

php遍历某文件夹下的所有文件和文件夹 function list_dir($dirpath){ if($dirpath[strlen($dirpath)-1]!="\\"){$dirpath.="\\";} static $result_array=array(); if(is_dir($dirpath)){ $handle=opendir($dirpath); while($file=readdir($handle)){ if($file=="."||$file==".."){continue;} if(is_dir($dirpath.$file)){ list_dir($dirpath...

限制文件下载速度php代码

如下代码实现php限制下载速度: /* Source: http://www.apphp.com/index.php?snippet=php-download-file-with-speed-limit */ /* set here a limit of downloading rate (e.g. 10.20 Kb/s) */ $download_rate = 10.20; $download_file = 'download-file.zip'; $target_file = 'target-file.zip'; if(file_exists($download_file)){ /* headers */ header('Last-Modified: '.gmdate('D, d M Y H:...

获得随机颜色的php代码

function randColor(){ $letters = "1234567890ABCDEF"; for($i=1;$i $pos = rand(0,16); $str .= $string{$pos}; } return "#".$str; } echo 'Random Color Text';?> php

执行 - 相关标签