PHP type Conversion

With type conversion, you can convert the value of one variable to another type. This conversion is the same as the C language type conversion. Simply insert the temporary data type that you want to convert in parentheses before the variable you

PHP gets all the links in a page

By using this code snippet, you can easily extract all the links on any Web page. $html = file_get_contents (' http://www.example.com '); $dom = new DOMDocument (); @ $dom->loadhtml ($html); Grab all the

PHP class definitions and class usages

Class EMP { var $name; var $address; var $dept; function Assign_info ($n, $a, $d) { $this->name= $n; $this->state= $a; $this->dept= $d; } function Display_info () { Echo ("

Send mail with Phpmail class

function Send_mail ($title, $content, $from, $to, $charset = ' GBK ', $attachment = ') { Include '/class/phpmail.class.php '; Baidu two down Header (' content-type:text/html; charset= '. $charset); $mail = new Phpmailer (); $

PHP extract the main color of the picture

$i = Imagecreatefromjpeg ("Image.jpg"); for ($x =0; $x for ($y =0; $y $rgb = Imagecolorat ($i, $x, $y); $r = ($rgb >>) & 0xFF; $g = ($rgb >> & 0xFF; $b = $rgb & 0xFF; $rTotal + =

A general method for obtaining remote images from PHP

function Auto_save_image ($body) { $img _array = Explode (' & ', $body); /* $img _array = array (); Preg_match_all ("/(SRC) =[\" |\ ' |] {0,} (http:\/\/(. *) \. (gif|jpg|jpeg|bmp|png)) [\"|\'| ] {0,}/isu ", $body, $img

PHP generates graphics verification code (mixed uppercase and lowercase letters and numbers)

Header ("Content-type:image/png"); $num = $_get[' num ']; $imagewidth = 60; $imageheight = 18; Srand (Microtime () * 100000); $numimage = Imagecreate ($imagewidth, $imageheight); Imagecolorallocate ($numimage, 183,

PHP code that prints data as a picture

$query = "SELECT count (IP) as count_ip from tb_count04"; Querying the total number of IP accesses in the database $result =mysql_query ($query); $countes =mysql_result ($result, 0, ' count_ip '); Creating a canvas

PHP Compressed pictures

function Scale_dimensions_within_limits ($w, $h, $max _w, $max _h) { $w is the width of the current rectangle $h is the height of the current rectangle $max _w is the maximum width a image can be sized $max _h is the maximum

PHP Create multi-level directory code

function Create_dir ($path, $mode) { if (Is_dir ($path)) {//Determine if the directory exists no, there is no creation echo "Directory". $path. "' already exists"; } Else {//does not exist create $re =mkdir (

PHP Processing checkbox check box form submission

The PHP form submits the page check box after the name to add [], so that the receiving page to get the correct results. The form is submitted with an array, and then the specific Vaule value of the form is obtained by accessing the array elements.

PHP implementation to get the Chinese first letter method

function Getfirstchar ($s 0) { $fchar = Ord (substr ($s 0, 0, 1)); if ($fchar >= ord ("a") and $fchar = ord ("a") and $fchar $s = Iconv ("UTF-8", "gb2312", $s 0); $ASC = Ord ($s {0}) * n + ord ($s Beckham)-65536; if ($asc >=

A general method of PHP for data paging

function Show_page ($count, $page, $page _size) { $page _count = ceil ($count/$page _size); Calculate the total number of pages $init = 1; $page _len=7; $max _p= $page _count; $pages = $page _count; Judging the

PHP download files from the network

Set_time_limit (0); Supports all file types URL here: $url = ' http://somsite.com/some_video.flv '; $pi = PathInfo ($url); $ext = $pi [' extension ']; $name = $pi [' filename ']; Create a new CURL resource

PHP File Upload Example

Handling code: Header (' Content-type:text/html;charset=utf-8 '); Ready to receive /* echo ' filename: '. $_files[' userfile ' [' name ']; echo ' File size: '. $_files[' userfile ' [' Size ']; Echo ' ERROR:

PHP Crawl Page code example

PHP (provided that curl is installed): $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, "http://www.xxx/"); curl_setopt ($ch, Curlopt_referer, "http://www.xxx/"); Curl_exec ($ch); Curl_close ($ch); PHP (does not

Intercept Chinese string PHP code

ord

/** * * Chinese string interception * @param string $string * @param int $sublen * @param int $start * @param string $code */ function Substr_zh ($string, $sublen, $start = 0, $code = ' UTF-8 ') { if

PHP Calendar Class Calendar control

} } } Class Calendarform { protected $year; protected $month; protected $day; protected $weekend; protected $currentdate; protected $dayofmonth; protected $day _count;

Full-width character converted to half-width character php function

/** * Full-width characters converted to half-width characters */ function Make_semiangle ($STR) { $arr = Array (' 0 ' = ' 0 ', ' 1 ' = ' 1 ', ' 2 ' = ' 2 ', ' 3 ' = ' 3 ', ' 4 ' = ' 4 ', ' 5 ' = ' 5 ', ' 6 ' = ' 6 ', '

Quick-Install PHP7 shell scripts

PHP7 was officially released in 201 May-December, with a much higher performance than the 5.6 release, so install PHP7 try it out in php.ini configurationZend_extension=opcache.soOpcache.enable=1Opcache.enable_cli=1Sure enough, performance has

Total Pages: 5208 1 .... 4768 4769 4770 4771 4772 .... 5208 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.