3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class Ymodulus { /** * This properties is meant to hold a list of new comers */ public $newComers; /** * This method is meant to determine if a student is in the list of newcomers *@Param string $newComer | i casted the variable to always return a string. *@return boolean. true|false. true if name is in list of newComers and false if its not. */ public function welcomes(string $newComer) { # here i am checking for the user inputed name in the array. Note am using the short form of if / else statement. return (in_array($newComers, $this->newComer)) ? true : false; } } //Usage $ymodulus = new Ymodulus(); $ymodulus->newComers =['MizMyColi', 'other New Bie']; $result = Ymodulus->welcomes('MizMyColi'); echo ($result === true ) ? 'MizMyColi Ymodulus welcomes you too the world of php': 'sorry not yet welcomed by ymodulus'; ?>
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "Ymodulus" in /in/kg2sd:28 Stack trace: #0 {main} thrown in /in/kg2sd on line 28
Process exited with code 255.
Output for 5.4.0 - 5.4.32
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/kg2sd on line 28
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/kg2sd on line 27
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/kg2sd on line 27
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/kg2sd on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/kg2sd on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/kg2sd on line 8
Process exited with code 255.

preferences:
139.75 ms | 401 KiB | 143 Q