Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 PHP


  Beauty of code : How to write graceful PHP code

Writing good code is an art. In order to achieve this, it is necessary to develop good programming habits at the beginning. Good programming habits not only contributes to the early project design (modular),but also allows you to the code easier to understand, so that the maintenance of the code is easier. Bad programming habits will result in more code bugs, and will make future maintenance work difficult.We introduce some good programming habits taking PHP as example. Hope this will help you.1. Planning code structureExcellent PHP code should have a clear structure. PHP object-oriented featu...

15,094 0       PHP GOOD CODE


  Why cannot compare double values directly for equality?

A question in PHP: Get some value from the database and use floatval() to convert it to floatint point value, then compare it with another value which is also converted to floating point value with floatval(). These two values are the same when using var_dump() to output, the two outputs are float(8.87), they are the same. But when comparing them for equality, the result is weird., they are not equal. Why?To analyze this question, we need to start with PHP data types. PHP uses weak types. In PHP, floating point values are stored using C's double precision type, so we need to understand how dou...

10,227 0       PHP FLOATING PRECISION COMPARE EQUALITY


  Case sensitivity in PHP

Case sensitivity in PHP is a bit messy. We recommend that you stick to the case sensitive rule in any language. Here we share some case sensitivity cases in PHP.1. Case sensitive1.1 Variable name is case sensitiveAll variables names are case sensitive, these include normal variables and superglobals such as $_GET,$_POST,$_REQUEST,$_COOKIE,$_SESSION,$_GLOBALS etc.<?php$abc = 'abcd';echo $abc; //Output 'abcd'echo $aBc; //No outputecho $ABC; //No output1.2 Constant name by default is case sensitive, usually use UPPER CASE for constant name<?phpdefine("ABC","Hello World");echo ABC; &nbs...

14,220 0       PHP SUMMARY CASE SENSITIVITY


  Install and remote access phpMyAdmin on CentOS

phpMyAdmin is a free and open source tool written in PHP intended to handle the administration of MySQL with the use of a Web browser. It can perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; or managing users and permissions.Today I walk through you the steps to install phpMyAdmin on CentOS. Actually, these steps are applicable to other Linux systems as well. 1. Download the phpMyAdmin from Sourceforge.net. Run command:wget -c http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-english.tar....

18,177 0       PHPMYADMIN LINUX DEMO INSTALLATION


  Output control functions in PHP

The Output Control functions in PHP allow you to control when output is sent from the script. This can be useful in several different situations, especially if you need to send headers to the browser after your script has began outputting data. The Output Control functions do not affect headers sent using header() or setcookie(), only functions such as echo and data between blocks of PHP code. These output control functions include ob_start(0, ob_clean(),ob_get_contents(), etc. To be honest, I am always mess up these ob_xxx() functions, some of them have similar functions and some of them can ...

6,411 0       PHP RELATIONSHIP OUTPUT BUFFER OB


  PHP to get long running process progress dynamically

Frequently in web applications, we may have a request to the back end system which may trigger a long running process such as searching huge amount of data or a long running database process. Then the front end webpage may hang and wait for the process to be finished. During this process, if we can provide the user some information about the progress of the back end process, it may improve user experience. Unfortunately, in web applications, this seems not an easy task because web scripting languages don't support multithreading and HTTP is stateless.  We now can have AJAX to simulate rea...

59,280 10       PHP AJAX DEMO PROGRESS LONG PROCESS


  Will PHP __autoload() function really affect performance?

IntroductionRegarding to PHP performance, the most frequently discussed is the __autoload() function. Many people say that this function will affect the performance very much, some other people say that opcode will affect __autoload() as well. So we will have some tests on these two.EnvironmentPHP 5.3.9 -- Launch under fastcgi modeNginx 1.1.12eAccelerator 0.9.6.1ScreenshotsLaunch pageeAccelerator(In php.ini) configurationFile structure(each Test file has over 6000 lines of code)Testing With eAccelerator cache and with __autoload() function loadedThe result after refreshing the web browserTotal...

3,815 1       PHP PERFORMANCE __AUTOLOAD() OPCODE


  Latest PHP patch cannot fix the bug

On Wednesday(2012-05-02), a remote code execution vulnerability in PHP was accidentally exposed to the Web, prompting fears that it may be used to target vulnerable websites on a massive scale. The bug itself was traced back to 2004, and came to light during a recent CTF competition.A CERT advisory on the flaw explains: “When PHP is used in a CGI-based setup (such as Apache's mod_cgid), the php-cgi receives a processed query string parameter as command line arguments which allows command-line switches, such as -s, -d or -c to be passed to the php-cgi binary, which can be exploited to dis...

15,574 0       PHP BUG PATCH BYPASSED