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,312 0       PHP GOOD CODE


  Tips for improving PHP efficiency

0. Using single quote to replace double quote to enclose string literal, this will be a bit faster. Because PHP engine will search variables in double quoted string.1. If a method in class can be declared as static, then make it static, this will be 4 times faster.2. $row["id"] is 7 times faster than $row[id]3. echo is faster than print, and you should use multiple parameters instead of string concatenation, i.e use comma(,) instead of dot(.) to concatenate string. For example echo $str1,$str24. Calculate the numer of loops before executing for loop, don;t calculate the number of loops in each...

14,963 0       PHP EFFICIENCY TIPS


  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,279 0       PHP SUMMARY CASE SENSITIVITY


  Understanding PHP's internal function definitions

Welcome to the second part of the “PHP’s Source Code For PHP Developers” series.In the previous part ircmaxell explained where you can find the PHP source code and how it is basically structured and also gave a small introduction to C (as that’s the language PHP is written in). If you missed that post, you probably should read it before starting with this one.What we’ll cover in this article is locating the definitions of internal functions in the PHP codebase, as well as understanding them.How to find function definitionsFor a start, let’s try t...

14,228 0       PHP INTERNAL FUNCTION DEFINITION RATIONALE


  Remote form submission

Remote form submission is way of submitting HTML forms from local to a particular remote server. This is used by many advertisers, spammers or even hackers to submit bad data to other websites in order to get what they want. They can write some automation scripts to help them do spamming.How can people do remote form submission and how to prevent this kind of attacks?Since a website can be accessed by almost every one, so one can save a local copy of a HTML form of a website through File->Save as on the browser. Then they only need to modify the action attribute of the form, instead of the ...

13,791 0       PHP SECURITY REMOTE FORM SUBMISSION


  Some tricks on PHP session

1. Session timeout problemThere is a nuance we found with session timing out although the user is still active in the session.  The problem has to do with never modifying the session variable. The GC will clear the session data files based on their last modification time.  Thus if you never modify the session, you simply read from it, then the GC will eventually clean up. To prevent this you need to ensure that your session is modified within the GC delete time.  You can accomplish this like below. if(!isset($_SESSION["last_access"]) || (time() - $_SESSION["last_access"]) >= ...

13,765 4       PHP SOLUTION SESSION TIMEOUT VARIOUS DOMAIN


  Install both 32 bit and 64 bit WAMP server

WAMP server is a platform tool for serving PHP applications on Windows. It includes a combination of Apache, MySQL and PHP service which can help developers test or run PHP applications with minimal setup.Sometimes one would first have a 32 bit version of WAMP installed and a few applications have been configured. But later s/he would mistakenly installed a 64 bit version of WAMP and somehow the 32 bit version configuration is overwritten. This causes a problem where the old applications configured for 32 bit WAMP will not function any more even if the 32 bit version of WAMP server is started....

12,489 0       PHP WAMP 64 BIT 32 BIT MULTIPLE VERSION


  Highly efficient PHP code writing

Next are some tips for writing highly efficient PHP codes. They are described below:0. Use single quote to replace double quote, this will be better since PHP will serach for variables in double quoted strings. Note, only echo can do this;1. If we can define methods of a class as static, then do it. It will increase access speed by 4 times;2. $row["id"] is 7 times faster than $row[id];3. echo is faster than print, and also use echo's multiple parameter format such as echo $str1,$str2 instead of echo $str1.$str2;4. When using for loop, make sure the maximum number of executions instead of calcu...

12,376 3       PHP TIPS CODE WRITING HIGH EFFICIENT