PHP command-line interface (CLI) includes a nifty option to quickly check for any syntax errors in a source code file. A simple check for a single file is given below. The option flag to check is -l (lowercase ‘L’).
Read More
Tag: php
Creating custom stream filters in PHP
In this post we will see how to create a custom stream filter. Streams, first introduced in PHP 4.3, provide an abstration layer for file access. A number of different resources besides files – like network connections, compression protocols etc. can be regarded as “streams” of data which can be serially read and written to.
Read More
‘isset’ construct and multiple parameters
PHP programmers are frequently into using the various is_x group of functions: is_int, is_null etc. All of this functions take a single parameter which leads you to believe that other similar constructs take only a single parameter. Like the isset and unset constructs, which by the way take multiple parameters as shown below, which might help you save some keystrokes.
Read More
Validating POST fields the easy way
Validating POST data from a form is a common requirement for a developer. If the number of form fields are few than the validation is a small matter. But the case is different when the form contains more than 15 or 20 fields and some of the fields are mandatory. The following code will give you an idea of how to easily validate mandatory fields, whatever the number of fields.
Read More
Creating a Figlet text in php
Zend_Text_Figlet is a Zend component which enables developers to create a FIGlet text. A Figlet is nothing but a technique of creating large letters using ordinary text. I don’t know how to make a use of this in my daily matters, but its a nice recreation. A short history on Figlet can be found here. An example and the code to generate it is shown below.
Read More
Easy way to build GET query strings in php
Passing variables with a url is such a frequent thing programmers do that most of you may think this post is unwarranted. We call this method of passing variables as GET, the other being POST. It is one of those things which can be easily done in php. Lets take an example. You are to query a database and for that you need to send three variables via GET – city, id, paid.
The common way to pass them via GET is to construct a query string as below:
Read More