php

Multiple Constructors in PHP

Feb
04

In most object-oriented programming languages such as Java, C++ and C#, you can define multiple constructors each having different signatures. The class calls correct constructor based on the number of parameters, and data type of input parameters. In PHP5, however, you can have one and only one constructor. Constructor in PHP is defined with a reserved keyword, __construct(). If the __construct function doesn’t exist, PHP5 will search for the old-style constructor function by the name of the class.

Posted By admin read more

PHP $_SERVER environment variable

Feb
04

PHP provides a large number of predefined variables to all scripts, and $_SERVER array is commonly used to refer server-specific environment information. Per PHP.net documentation, the $_SERVER variable is defined as:

Posted By admin read more

Double and Triple equal operators in PHP

Feb
04

Even if you're a seasoned programmer, you may not have seen triple equals operator in most programming languages. In PHP, the triple equals (===) operator was introduced in version 4 and it checks for equality similar to double equals (==) operator but also checks type of variable. Here are the differences between single, double and triple equals operators.

A single equals operator (=) is an assignment operator - take what's on the right as an expression and save it in the variable named on the left.

Posted By admin read more

Assigning name/value pair from a single element array to variables

Feb
04

How do you extract name/value pair of an associative array into PHP variables? Whether it's a single element array, or multiple element array the procedure is identical.

Posted By admin read more

How to install mod_php5 on SuSE 11.1?

Feb
04

Installing apache2, php5 and mod_php5 shouldn't be too hard, but it took me nearly 2 hours trying to get this installed on SuSE v11.1. The later SuSE 11.4 works just fine by installing the required modules with zypper, but the SuSE 11.1 wouldn't work right out of the box.

Here are the steps required to get the mod_php5 to work on SuSE 11.1. The v11.1 installs php5-5.2.6 where v11.4 installs php5-5.3.5. We had to downgrade the php due to package dependency issues.

1. Add official OpenSuSE repository

Posted By admin read more

Previsor PHP assessment test

Feb
04

With more and more companies using pre-employment screening test such as the one provided by Previsor, LAMP developers and PHP developers should hone their technical skills to prepare for their next career. Having taken one, Previsor assessment test resembles College Board Tests such as the ACT and SAT, which tests students' general understanding of the subject (in this case "PHP"). PHP, especially version 5, is a great scripting language to develop web applications very rapidly with a minimum effort.

Posted By admin read more

PHP File Upload

Feb
04

PHP provides file upload variable, $_FILES associative array, to permit file upload to an web server. To upload a file to the server, an HTML form must be composed to allow a user to select a file from local filesystem to upload.

HTML Form: Create a HTML file with the following content, and call it form.html.

Posted By admin read more

How to change the date.timezone in Linux/PHP?

Feb
04

If your date.timezone is not properly set, your web application will not display your local time correctly.  The default date.timezone will be set to the server time zone. If you (or your company) is located in different time zone from the server, you may have to override the value in your PHP application.. The date.timezone can be set at the system level, PHP level or application level.

Linux Server Timezone

To set the date.timezone value globally within the server, you'll have to follow the steps outlined below.

Posted By admin read more

How to display PHP errors?

Feb
02

On a production server, you will definitely want to turn off errors from displaying on the screen due to security and usability reasons but what do you do when you're on a development machine trying to debug a malfunctioning PHP script? PHP gives a programmer an ability to control logging of errors, and the types of errors to be displayed. You may enable PHP error display in one of two ways.

1. You may turn on error display at the script level when a server level error display is turned off.

Posted By scott read more

How to upgrade PHP 5.1.6 to PHP 5.3.x on CentOS?

Feb
02

I have been using CentOS 5.x for several years now, but PHP is still at 5.1.6 on the latest CentOS 5.7. More and more applications are now require higher versions of the PHP including Drupal 7 and Wordpress 3.2. I have upgraded a number of my servers to PHP 5.3.x over the course of last couple of years, and demand is higher each year. I have been using several custom repositories to upgrade the PHP to 5.3.x in the past, but using php53 packages makes it easier than ever to upgrade php to 5.3.x.

Posted By admin read more

Pages

Subscribe to RSS - php