Library website templates that allow PHP programming to get twice the result with half the effort

Source: Internet
Author: User
When using php to develop website templates, using object-oriented methods 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 for PHP development websites are excellent on the Internet.

When using php to develop website templates, using object-oriented methods 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.win4000.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.win4000.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!



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.