Some php Coding tips (php tips) [2011/04/02 Last updated]_php tutorial

Last update: 2011/04/02 1. Use list to achieve a specific segment value after getting explode: List (, $mid) = explode ('; ', $string); 2. Replace is_null with NULL = = =: Is_null and NULL = = = are exactly the same effect, but save one function

How to use the Agent _php Tutorial under PHP via file_get_contents

PHP uses File_get_contents's proxy method to get the code for a remote Web page. Copy CodeThe code is as follows: $url = "http://www.jb51.net/"; $ctx = stream_context_create (Array ( ' http ' = = Array (' timeout ' = 5, ' Proxy ' = ' tcp://60.175.2

Error collection in PHP development, not regularly updated. _php Tutorials

Fatal Error:non-static Method Conn::__construct () cannot be called statically in/file.php There is no static method (inside this refers to a method parameter, a string type) and cannot be referenced from a static context. Fatal error: [] operator

PHP get the global variable Code _php tutorial

Copy CodeThe code is as follows: function Cleanglobal ($global _array, $arg, $specialchars = true, $default = null) { if (Key_exists ($arg, $global _array) && $global _array[$arg]! = null && $global _array[$arg]! = "") { if ($specialchars) { Return

How to use PHP functions in smarty templates _php tutorial

Sample1 Copy CodeThe code is as follows: What if I use a function like iconv that has three parameters? If written as: Sample 2 Copy CodeThe code is as follows: An error message is displayed when you execute it. Therefore, the study will find

Some ways to optimize PHP efficiency and improve PHP performance _php Tutorial

1, in the case can be replaced with file_get_contents file, fopen, feof, Fgets and other series of methods, as far as possible with the file_get_contents, because his efficiency is much higher! But pay attention to the PHP version of

A classic example of PHP code optimization _php Tutorial

I used the method of distinguishing blocks by key, then assigning the block to other variables, and then doing some work, so I used a lot of for and foreach, and the code was very large, so I was back. After the above guidance, found really good

PHP XMLHttpRequest Code _php Tutorial for implementing HTTP requests in ASP

Class Name: HttpRequest ($url = "", $method = "GET", $useSocket =0) The $url is the requested address; The default request method is GET, $useSocket defaults to 0, the Fsockopen method is used, and the Socket_create method is used if set to

Code _php tutorial for Flash connection database with PHP

PHP Code: Copy CodeThe code is as follows: /*/flashservices/services/catalog.php */ Class Catalog { var $products _array = Array (); Constructor:contains the list of methods available to the gateway function Catalog () { $this->methodtable = Array

PHP stream_context_create () Role and usage Analysis _php tutorial

Role: Create and return a text stream and apply various options for the special process of fopen (), file_get_contents () such as the time-out setting, proxy server, request method, and header information settings for the process. Function

PHP Read access data to MySQL code _php tutorial

Copy CodeThe code is as follows: Header (' ontent-type:text/html;charset=gb2312 ');//Avoid garbled output $dbhost = "localhost"; $dbuser = "root"; $dbpassword = "123456"; $dbname = "139miaosha"; Mysql_connect ($dbhost, $dbuser, $dbpassword) or Die (

PHP expects parameter 1 to be resource, array given error _php tutorial

If you are using a class that is well-encapsulated For example function Fetch_array ($query, $result _type = Mysql_assoc) { Return mysql_fetch_array ($query, $result _type); } [/code] will report this error This is supposed to be, you pass the

A tragedy of the PHP array? _php Tutorials

Copy CodeThe code is as follows: $a = 1; $b = 2; $t = Array ( Array (' A ', ' string ', $field [' a ']),//Name if ($a = = $b) {Array (' B ', ' 1 ')} ); Print_r ($t); Exit 1, because the array length is longer. Didn't notice. 2, development code

PHP using transactions in PDO (Transaction) _php Tutorial

And, in the course of execution, if one of the executions fails, you can roll back all the changed operations. If the execution succeeds, the sequence of operations will be permanently valid. The transaction solves the problem of being out of sync

PHP Records users visited products, in the cookie record product Id,id get product Information _php Tutorial

1. Test method www.xxx.com/test.php?content_id= own definition, such as: 44 Copy CodeThe code is as follows: $content _id = Array ();//1. Creating an array $content _id[] = $_get[' ContentID '); 2. Insert the ID of the docking to the array if

PHP uses GD library to generate high quality thumbnail images _php tutorial

The following is the PHP source code (resizeimage.php). Copy CodeThe code is as follows: $FILENAME = "Image.thumb"; Create the width of the picture $RESIZEWIDTH = 400; Height of the resulting picture $RESIZEHEIGHT = 400; function Resizeimage ($im,

PHP Write simple chat Room Code _php tutorial

index.php Copy CodeThe code is as follows: Live Chat _a.php Copy CodeThe code is as follows: Chat Room $person = @$_post[person]; $msg = @$_post[message]; if ($person! = "" && $msg! = "") { $handle = fopen

How to install Configuration FCKeditor Editor under PHP _php tutorial

First, PHP calls the FCKeditor method. Second, JS call FCKeditor method. Copy CodeThe code is as follows: Require_once (Path_pre. " Fckeditor.php "); Contains the FCKeditor class, $oFCKeditor = new FCKeditor (' content '); Create a FCKeditor

PHP implementation code for quality (prime number) _php tutorial

Copy CodeThe code is as follows: Class Timer { var $time _start; var $time _end; function __construct () { $this->time_start = 0; $this->time_end = 0; } function timer () { $this->__construct (); } function Start () { List ($usec, $sec) =

PHP form Submission Problem Resolution _php Tutorial

In this record, can not fall in the same place in the future! The database is a BBS, the table is test. Three fields, respectively, Id,name,sex. The ID is auto_increment. The PHP file that connects the database conn.php content is Copy CodeThe code

Total Pages: 5208 1 .... 4302 4303 4304 4305 4306 .... 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.