Code Learning for PHP string interception

Intercept UTF8 string function Utf8substr ($str, $from, $len) { Return Preg_replace (' #^ (?: [\x00-\x7f]|[ \xc0-\xff][\x80-\xbf]+) {0, '. $from. '} '. ' (?: [\x00-\x7f]| [\xc0-\xff] [\x80-\xbf]+) {0, '. $len. '}). * #s ',

Input validation using the filter function in PHP

if (Isset ($_get["value"])) { $value = $_get["value"]; } else { $value = false; } if (Is_numeric ($value) && ($value >= && $value Run My Code } else { Handle the issue }

Use Phpexcel to export data to excel in CI

Class Table_export extends Ci_controller { function __construct () { Parent::__construct (); Here you should add some sort of user validation To prevent strangers from pulling your table data } Function index

Examples of PHP singleton patterns

!--? php /** * by bbs.it-home.org * 2012-12-26 */ class mysql{ //This property is used to save an instance private St atic $conn; //constructor is private to prevent

Learn the use of clone in PHP

Class Person { Private $name; Private $age; Private $id; function __construct ($name, $age) { $this->name = $name; $this->age = $age; } function SetId ($id) { $this->id = $id; }

The original Super simple PHP framework

Main ideas:PHP is now widely used, and everyone is talking about OOP, MVC. I do not know these things very much, many places are not comprehensive, I hope you give correct.This framework is also guided by MVC, using the OOP idea and adding some

How to forge IP sources with curl in PHP

$ch = Curl_init (); curl_setopt ($ch, Curlopt_url, "http://localhost/2.php"); curl_setopt ($ch, Curlopt_httpheader, Array (' x-forwarded-for:8.8.8.8 ', ' client-ip:8.8.8.8 '));//ip curl_setopt ($ch, Curlopt_referer,

PHP supports a function to cut Chinese characters.

Support for the cutting of Chinese characters, will not appear? The half Chinese characters Chinese character cutting, can prevent the occurrence of half Chinese characters function Substr_cut ($title, $length =8) { if

Pinyin based on Chinese characters, with encoding function

Pinyin based on Chinese characters, with encoding function /** * pinyin.php * Author: Cold cloud **/ function Pinyin ($_string, $_code= ' gb2312 ') { $_datakey =

Zendframework Configuration Instance

Zendframework Configuration Instance [Production] phpsettings.display_startup_errors = 0 phpsettings.display_errors = 0 Includepaths.library = Application_path "/.. /library " Bootstrap.path = Application_path

PHP Cache Class

Define (' Cache_root ', DirName (__file__). ' /cache '); Cache Storage Directory Define (' Cache_time ', 1800);//cache time Unit seconds Define (' Cache_fix ', '. html '); $CacheName =md5 ($_server[' Request_uri '). Cache_fix;

Virtual agents implement lazy loading

The goods are learned from the "Enterprise Application Architecture Model" of Martin great God, and the features of the auxiliary PHP Dynamic language can be deferred loaded (lazyload) much more easily than Java. The rationale is that a virtual

Escape JavaScript code Tag function

from Phpcms /** * escaped JavaScript code tag * * @param $str * @return Mixed */ function Trim_scrip T ($str) { if (Is_array ($STR)) { foreach ($str as $key = $val) {

PHP class automatic loading

The rare has built-in class auto-mount functionality that is used directly without a require (include) class file when using a class.This kind of automatic loading function is very independent, if you need, you can directly in other frameworks (any

jquery (jcrop) +php cut pictures by coordinates

/** * Goofy 2011-11-29 * Image processing: According to the coordinates passed over the parameters, X,y,w,h, followed by the selected x-coordinate, y-coordinate, W-width, h-height * through the Imagecopy () method to copy the area to the first step

Introduction to PHP Timed execution methods

#!/usr/bin/php-q $file = "/var/www/". Date (' H '). ' _ '. Date (' I '). ' _ '. Date (' s '). TXT '; File_put_contents ($file, date (' y-m-d ')); ?> Copy CodeThen chmod +x test.php gives test.php executable

Smarty Cache Application and cleanup

First, the configuration of smarty cache $smarty->cache_dir = "/caches/"; Cache directory $smarty->caching = true; Cache is turned on, flase cache is invalid $smarty->cache_lifetime = 60; SustainedFirst, the configuration of smarty cache

[Rao] using Java to manage thousands of Linux servers _ get Started

Former club is a game company, the boss is very good, then the work has left a lot of their own original management scripts. Now share in the office environment using Java, Jsch login VPN Management Linux script (here to implement Java call backup

Socket usage Related

Learned in a small exercise program Package com.sdut.edu.tools; Import Java.io.BufferedWriter; Import java.io.IOException; Import Java.io.InputStream; Import Java.io.OutputStreamWriter; Import

Get Domain Name

I'm looking at that Ecmall core file ecmall.php, see this function is written relatively clear, take out to share under function Get_domain () { /* protocol */ $protocol = (isset ($_server[' https ") && (strtolower ($_server['

Total Pages: 5208 1 .... 5065 5066 5067 5068 5069 .... 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.