Class libraries that allow PHP programming to get twice the result with half the effort

Source: Internet
Author: User
Tags php website

When developing a website using php, using the object-oriented method can indeed improve the code reuse rate and reduce code redundancy. What is more friendly to beginners is that most of the class libraries required by PHP development websites have excellent class libraries on the Internet. As a programmer, the wheel cannot be repeatedly created, so I sort out the class libraries that I usually use and hope to be useful to my PHP study webmaster friends.

I. Collection class library, snoopy. class. php. (Please download the class library on Baidu without duplicate names)

Collection is essential for most webmasters. Many webmasters may directly use the cms built-in collection functions such as dedecms, but sometimes the website does not need to use the cms or cms built-in collection functions to meet our needs. You can use this collection class library. It is easy to use.

Demo:

// Load the Class Library File include ("snoopy. php ");

// Page address to be collected

$ Url = "http://www.www.shlongyingjixie.com ";

$ Snoopy = new Snoopy;

// Capture the page

$ Snoopy-> fetch ($ url );

// Output the html of the captured page

Echo $ snoopy-> results;

Next, use a regular expression to match the content you need. In this way, the collection is complete. Easy!

Ii. Image Processing class library, PHPThumb, (github.com/masterexploder/PHPThumb ). Note that this class library is named phpthumb with the same name as it is case-sensitive, so pay attention to it when searching documents.

In the process of website construction, there are a huge number of images to be processed. It is very tedious to use the php image function to process images. It is very difficult for new users to master. Now we can use the PHPThumb class library to process images, including image size adjustment, image capturing, image watermarking, and image rotation.

Demo:

// Load the class library file

Require_once 'path/to/ThumbLib. inc. php ';

// Instantiate the class library. The address of the image you want to process can be a network address or a local address.

$ Thumb = PhpThumbFactory: create ('HTTP: // www.shlongyingjixie.com /');

// Scale down the image to a maximum width of PX or a maximum of PX. When only one parameter is input, the maximum width is limited.

$ Thumb-> resize (100,100 );

// Reduce the image proportional ratio to the original percentage. For example, 50 is the original 50%.

$ Thumb-> resizePercent (50 );

// Intercept a 175px * 175px image. Note that this is the intercept. the excess part is directly cropped, not forcibly changed.

$ Thumb-> adaptiveResize (175,175 );

// Extract a PX * PX image from the image center.

$ Thumb-> cropFromCenter (200,100 );

// The first two parameters are the coordinates X and Y in the upper-right corner of the image to be extracted. The following two parameters are the width and height of the image to be solved.

$ Thumb-> crop (100,100,300,200 );

// Reverse the image clockwise to 180 degrees

$ Thumb-> rotateImageNDegrees (180 );

There are more functions in this class library. If you need to process images when developing a PHP website, read the documentation of this class library to ensure that you can process images easily, you no longer have to deal with the dozens of annoying php image processing functions! Reprinted Please note: http://www.shlongyingjixie.com

 

Related Article

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.