PHP Script

Detecting UTF BOM using PHP

You need to detect the three bytes and remove the BOM. Below is a simplified example on how to detect and remove the three bytes. Here is a script to recursively check php files for BOM (ByteOrderMark)

How to install Wkhtmltopdf in Fedora 17

wkhtmltopdf is an excellent opensource tool for converting html to PDF or an Image like JPEG, PNG etc.. It is available under GNU/GPL and written in C++ programming language. It can convert any HTML web page to PDF with Options to add Header and Footer. Also with Table of Content writing Option. It is available for both 32 and 64 bit Linux systems. For dowloading 32bit tool use the below command. For downloading 64bit tool use the below command. Extract the Files: Install...

Backup mysql database with php and zip

Many php applications prefer to backup the mysql database from within the application and save it as an archive. The mysqldump commandline utility can be used to perform this function of backing up a mysql database as sql file. The command would be like this : The above command shall dump the database named $db_name into a sql file in directory $dir. This sql file shall be next zipped using php's Ziparchive class. In the above example backups/backup.sql is the path to the sql fil...

PHP library for PDF Word Excel

PHP Excel Reader - Parse and retrieve information from XLS files http://code.google.com/p/php-excel-reader/ PHPExcel - OpenXML - Read, Write and Create Excel documents in PHP - Spreadsheet engine http://phpexcel.codeplex.com PHPDocX is a PHP library designed to generate completely dynamic, fully customizable and digitally signed Word documents. http://www.phpdocx.com Demo: http://www.phpdocx.com/demo/sample-word-report HTML 2 PDF - Get a HTML text and generate a PDF file to make it ...

How to get a list of month between two dates using PHP

This demo will show you how to get a list of month between 2 dates. First, let's find out how to get the next month : Now, we can get a month list between 2 dates. The result will return :

Import CSV File into PHP Array

A Comma-separated values (CSV) file stores tabular data (numbers and text) in plain-text form. Often it is one record per line seperated by a comma or any other delimeter. The comma , is often used in USA/UK CSV files where Germany often uses a ; instead This is an example of a simple CSV file that has 4 fields and 2 records (1 per line) In PHP it is often useful to be able to read a CSV file and access it’s data. That is where the fgetcsv() funtction comes in handy, it will re...

Capture Image Screenshots with PHP

Since PHP 5.2.2 it is now possible to capture a website or any window’s screenshot to an image with PHP as long as it is running on a Window’s machine. Most web-servers are running Linux but this could be useful for a tool on your home Dev server. Capture Whole Screen Capture an Application’s Window

Using CURL follow redirects to get final url

This example code shows you how to use curl to follow redirects and get final url.

ThinkPHP中forward和redirect的区别

ThinkPHP中forward和redirect的区别在那里呢? 首先看代码注释: forward: 执行某个Action操作(隐含跳转) 支持指定模块和延时执行 redirect: Action跳转(URL重定向) 支持指定模块和延时跳转 其次看代码组织,二者的行为是不同的: forward: redirect: forward是通过框架内部的ACTION和MODULE的调用,实现页面显示的是另一个你想要的内容。 redirect则是通过改变URL地址栏,直接跳转过去的。 上论坛搜索,发现老大给出了一些指点,其说明如下: 可以把forward看成是隐含跳转,rediret是直接跳转。 redirect是会改变url ,跳过去执行另外的操作 forward只是隐含执行一个操作方法,url本身并不会跳转(这个其实不是绝对的,因为隐含执行的操作可能会有一个重定向的过程) 例外论坛里有位兄弟已经给出了forward的用法: