3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generatePassword($username, $password ) { /* 1. RESULT = LOWER_CASE ( username ) + PASSWORD 2. RESULT = LOWER_CASE ( SHA1_HEX(RESULT) ) 3. RESULT = SESSIONID + RESULT 4. RESULT = UPPER_CASE ( SHA1_HEX(RESULT) ) */ if( $this->_sessionid ) { //1. $result = strtolower( $username ) . $password; //2. $result = strtolower( sha1( $result ) ); //3. $result = $this->_sessionid . $result; //4. $result = strtoupper( sha1( $result ) ); } else { $result = false; } return $result; } print_r(generatePassword('599750531', '4321')); ?>
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Using $this when not in object context in /in/Rns08:10 Stack trace: #0 /in/Rns08(27): generatePassword('599750531', '4321') #1 {main} thrown in /in/Rns08 on line 10
Process exited with code 255.
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Fatal error: Using $this when not in object context in /in/Rns08 on line 10
Process exited with code 255.

preferences:
176.03 ms | 402 KiB | 223 Q