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

SEARCH KEYWORD -- Php



  PHP 7 is coming soon

After a few RCs, PHP 7 will be officially released on November 12, 2015. This is a major release of PHP since PHP 5.6. @Laruence, one of the core contributors of PHP, has posted this news on Weibo(China's Twitter).  This is a one month later than the expected time as recorded in PHP 7 timeline. But it's not that late. The new release will come with a few features including: Scalar type declaration, you can define variable like int now Return type support. Besides declare scalar type ...

   RELEASE DATE,PHP7     2015-11-08 09:13:37

  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,$str...

   PHP, efficiency, tips     2012-10-01 19:39:06

  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....

   PHP,Good code     2012-08-26 12:23:03

  A trap about PHP random number

The method to get random number in PHP is very simple, we only need to use rand() function. int rand ( int $min , int $max ) One function call can return the random number in a specified range. But in fact, the random number in computer is actually pseudorandomness, generally to increase the randomness, we may set a random seed before calling rand(). void srand ([ int $seed ] ) According to other language features, we should pass a time value as a parameter to the srand() function, generally...

   PHP,rand,srand,mt_rand     2013-06-07 09:10:10

  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->S...

   PHP,Security,Remote form submission     2013-07-14 01:04:49

  What does session_destroy() do in PHP?

In PHP manual, the description for session_destroy() function is : session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called. I am confused about this description. If this function destroys all session data, then why the global variables associated with the session are not unset? Why can we u...

   session_destroy,session_start     2013-08-31 09:59:05

  Should we use Abstract class or Interface?

When we write programs, we may often get into a situation where we don't know whether we should use Abstract class or Interface when we want to define an abstract object. These two are very similar and they are interchangeable in many cases. On Stackoverflow, this question is asked lots of times and it's related to many programming languages. Also in the official documentation of PHP regarding the Abstract class and Interface, people are arguing about this. To understand this question, their dif...

   DIFFERENCE,INTERFACE,ABSTRACT CLASS,COMPARISON,OOP     2013-04-15 11:44:36

  Social media sharing codes

Social media is becoming a very important traffic source to one website. We can see social media share buttons or links in most websites ranging from news website to personal blogs. It is also a very important optimization area where many SEO experts recommend. There are many social medias we can share our links to such as Facebook and Twitter. Most of these website provide share button for us to easily integrate them into our websites, but these buttons usually have default styles(fixed size, f...

   Social media,Share button,Cutomize     2013-07-18 23:12:45

  Optional arguments in PHP function

In PHP, we can define our own functions which can accept optional number of arguments. In this kind of functions, the optional argument should be set with default value.Fox example, the next code example will illustrate this:<?php function func($name,$type=NULL) { echo "$name $type"; } func("Hello"); echo "<br />"; func("Hello","world"); echo "<br />";?>Here $type is an optional argument. It must be set with a default value either NULL or some other value. Quite simple....

   PHP,optional,arguments,user defined func     2011-03-28 12:35:20

  What you may not know about PHP session

When we access one website, the site usually should have a mechanism to keep track of the status of the user on the site. There are a few mechanisms supported by many server side languages to help track user status such as session and cookie. Today we will talk about session, when creating a session, we need to keep track of many data, besides user data, we also need to tell the server what is the timeout of the session so that we can garbage collect the session data which should not be stored a...

   PHP session,session timeout,example     2013-07-06 08:44:18