[French Vocabulary] boute-en-train

boute en train

boute-en-train nom commun – masculin ou féminin ; invariable
1. personne qui stimule la gaieté générale

  • elle essaie toujours de jouer les boute-en-train
boute-en-train adjectif ; invariable
1. qui stimule la gaieté générale

  • un esprit boute-en-train

擅长逗大家乐的人, 善于活跃聚会气氛的人; 试情公畜

(第二个解释还需斟酌)

[PHP] PHP Warning: Module ‘mcrypt’ already loaded in Unknown on line 0

Like in the title, PHP Warning: Module ‘mcrypt’ already loaded in Unknown on line 0.
When we launch whatever a command PHP, for example php -v, we will see the warning :

# php -v
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
...

This warning was caused by the duplicated configuration of the mcrypt extension.

To check it, we can use this command (the path could be changed depends on the local configuration):

grep "extension=mcrypt.so" /etc/php5/cli/php.ini

and

grep "extension=mcrypt.so" /etc/php5/cli/conf.d/mcrypt.ini

If the two command return the same thing : “extension=mcrypt.so”, this means the extension is included two times.

The solution is simple, juste remove one of these configuration, that will be ok.

[PHP] PHP Fatal error can’t use method return value in write context

Context :
Development with PHP

Error message :
PHP Fatal error can’t use method return value in write context

Code generated error :

if(empty(preg_match($pattern, $subject))){
  ....
}

Error reason (from php.net) :

Note:
Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error. In other words, the following will not work: empty(trim($name)). Instead, use trim($name) == false.

Code corrected :

preg_match($pattern, $subject, $match);
if(empty( $match )){
  ....
}

[PHPUnit] Testing output

Test contains not only unit test, integration test, but also the output of screen, including files etc.

For example, with the function exceptOutputString, we can test the string output by echo or print.

<?php
class OutputTest extends PHPUnit_Framework_TestCase
{
    public function testExpectFooActualFoo()
    {
        $this->outputString();    // Call my local function
        $this->expectOutputString('Hello world!');    // Comparaison
    }

    // local function 
    private function outputString()
    {
        echo "Hello world!";
    }
}
?>

Ref. Methods for output testing