Wrapping Text using PHP

May 1st, 2013 by laeeq | No comments

Sometimes we need to wrap text to exactly accommodate a certain width of text or allowing browsers to wrap text whenever required. You can use PHP’s wordwrap() function to wrap a string into new lines when it reaches a specific length. This function limits text display to a particular column size, thereby allowing precise control over how text is rendered on a Web page. By default, wordwrap() wraps strings at column 75 using the standard newline sequence.

Read Full Post »

PHP 5.5 beta 4 is now available

April 26th, 2013 by laeeq | No comments

The PHP development team announces the release of the 4th beta of PHP 5.5.0. This release fixes some bugs against beta 3 and cleans up some features.

PHP 5.5.0 beta 4 is shipped with some bug fixes. Here is the list:

  • Fixed bug #64677, execution operator “ stealing surrounding arguments.
  • Fixed bug #64342, ZipArchive::addFile() has to check for file existence.
  • Fixed Windows x64 version of stream_socket_pair() and improved error handling.
  • Remove curl stream wrappers.

Read Full Post »

Swapping Array Keys and Values

April 13th, 2013 by laeeq | No comments

If you want interchange the keys and values of an associative array. It’s very easy, just use PHP’s array_flip() function which perform a very specialized task. It reverses the key-value relationship for all the elements of an associative array and returning a new array that is the mirror image of the original. Read Full Post »

PHP Security

April 5th, 2013 by Adrian Stolarski | No comments

When it comes to PHP, some 99% of amateur sites and 60-70% of all sites use the professional scripting language called PHP. But is it safe to use PHP? Does the implementation of the language not have any gaps that are critical to the operation of our applications? But remember that security problems do not arise just from the language itself, but also from the programming skills of those who write PHP scripts. Of course, most of the errors can be avoided. But, how can they be avoided? This article is an attempt to answer that question. We will discuss most of the issues with which we meet in life everyday. So let’s start our adventure. For the purposes of this article, we assumed that we do not have access to php.ini, and all operations will be performed from within PHP.

Read Full Post »

Working with Image Metadata in PHP

March 27th, 2013 by laeeq | No comments

Sometimes you want to extract the descriptive information embedded in an image, such as the metadata or thumbnails placed in digital photos. For this, you can use PHP’s Exchangeable Image File Format (EXIF) functions. EXIF is a standard for storing descriptive metadata in image files, particularly JPEG and TIFF files.

Read Full Post »

Protecting Your Public E-mail Address

March 17th, 2013 by laeeq | No comments

If you want to protect a publicly displayed email address from being captured by an e-mail address harvester. To protect the email address, you can manage the email address which is only read by human being but not recognized as a standard e-mail address to a program. For I have a written a simple php function which convert special symbol in an email address with English words, making the e-mail address unrecognizable as such to an address harvester. So @ becomes at, _ becomes underscore, and – becomes dash. Read Full Post »

Converting Between Relative and Absolute File Path

March 2nd, 2013 by laeeq | No comments

To convert a relative path to an absolute file path, use PHP’s realpath() function. This function performs “path math” means translating all the relative locations in a path string to return a complete absolute path.

If we pass “.” as parameter in below example

  1. <?php
  2. $abs_path = realpath(“.”);
  3. echo $abs_path;
  4. ?>

Read Full Post »

Parsing File Paths with PHP

March 2nd, 2013 by laeeq | No comments

If you want to extract the path, file name, or extension path from a file path. You can use PHP’s pathinfo() function to automatically split the file path into its individual components.

Example code:

  1. <?php
  2. $path=“/etc/sendmail.cf”;
  3. $data=pathinfo($path);
  4. print_r($data);
  5. ?>

Read Full Post »

How to remove HTML Comments with PHP?

March 2nd, 2013 by laeeq | No comments

I think when sending content to users, there is no reason for HTML commends to be sent to the users. It generally increases load time. You can easily remove unwanted comments from html content using PHP regex.

You can use below PHP function:

  1. <?php
  2. function removeComments($html = ) {
  3. return preg_replace(‘/<!–(.|\s)*?–>/’, , $html );
  4. }
  5. ?>

Read Full Post »

How to access .htaccess values?

March 2nd, 2013 by laeeq | No comments

You know that you can get value entered by user with .htaccess pop-up? It’s actually very easy.

You can use this:

  1. <?php
  2. $_SERVER['REMOTE_USER'];
  3. ?>

Read Full Post »