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

 ALL


  Which one has a worse reputation, JavaScript or PHP?

There has a been a lot of criticism of PHP over being a badly designed programming language. JavaScript seems quite a similar language with loose-typing and flexible array declarations/memory management, but is widely adopted by industry leaders such as Google. Google even has a JavaScript style guide. Many people think that PHP has a worse reputation than JavaScript. Carlos Ribeiro gave his analysis on a high level which doesn't touch the language syntax.Attributing JavaScript success to it being "the only language for the job" is unfair. JavaScript is hands down a much better language than P...

10,299 0       PHP JAVASCRIPT COMPARISON REPUTATION


  PHP Apache MySQL Set-up Note

With the emergence of WAMP, LAMP, PHP developers are liberated from the tedious work of setting up PHP environment. Since PHP, Apache and MySQL are so tightly bundled, WAMP and LAMP provide a setp solution for setting up a PHP environment which includes the programming programming environment, server and database. But for a PHP who wants to learn more, you have to try to set the PHP environment yourself by installing PHP, Apache and MySQL manually and configuring them.Below is a simple note on how to setup the PHP environment on Mac OS X. This setup guide should also be helpful on other system...

4,505 0       PHP APACHE MYSQL


  10 less known but useful PHP functions

PHP has abundant built in functions. As PHP developers, we may have used many of them. But there are still some useful functions we may not be so familiar with. In this post, we will introduce some of them.levenshtein()Have you ever wondered how to check differences between two works? This function just does what you want. It can tell you how much the difference is between two words.<?php$str1 = "carrot";$str2 = "carrrott";echo levenshtein($str1, $str2); //Outputs 2?>get_defined_vars()This is a very useful function when you wants to debug your codes when there are some issues. It will re...

6,527 0       PHP FUNCTION


  Set PHP session timeout

There are many different discussions about PHP sessions. We may often face some weird issues while handling PHP sessions. Sometimes session is expired earlier than expected. Or sometimes the session is not expired. This introduces many confusions.Today we discuss how to set PHP session timeout correctly today. In php.ini, there are three key parameters which will affect the session timeout. session.gc_maxlifetime, session.gc_probability and session.gc_divisor. session.gc_maxlifetime defined the lifetime of a session in seconds which indicates when the session will be garbage collected. Then se...

21,241 3       PHP SESSION TIMEOUT


  A trap in PDOStatement::bindParam

First, let's check out below codes:<?php$dbh = new PDO('mysql:host=localhost;dbname=test', "test"); $query = <<prepare($query); $bind_params = array(':username' => "laruence", ':password' => "weibo");foreach( $bind_params as $key => $value ){ $statement->bindParam($key, $value);}$statement->execute();What is the SQL executed finally? Is there any problem with above codes?Many people may think the query executed is :INSERT INTO `user` (`username`, `password`) VALUES ("laruence", "weibo");But the query actually gets executed is :INSERT INTO `user` (`username`, `passwor...

9,191 1       PHP TRAP BINDPARAM


  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,741 0       PHP SECURITY REMOTE FORM SUBMISSION


  TIOBE: PHP is coming back

TIOBE released the programming language index for July 2013. The highlight of this month is that PHP is coming back. It ranks the fifth and has an increase of 1.54% compared to January. There are no changes in the ranking for the top 4 languages. The reason why PHP is back may be attributed to the new PHP Zend Framework that was released in September 2012, but this reason is not very convincing. PositionJul 2013PositionJul 2012Delta in PositionProgramming LanguageRatingsJul 2013Delta Jul 2012Status11C17.628%-0.70%  A22Java15.906%-0.18%  A33Objective-C10.248%+0.91% ...

47,294 7       PHP TIOBE ZEND FRAMEWORK JULY


  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 we may pass millisecond or microsecond. Starting from PHP 4.2, srand() will be automatically called whe...

11,508 0       PHP RAND SRAND MT_RAND