3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * Generating Gallery Vieuw * * Generating a simple gallery overview, * with Planned !possible extended MySQL Description support * * PHP Version 5 * * @category Gallery/Images * @author Diederick Bruin DDABruin@gmail.com * @copyright 2014 http://DiederickBruin.nl/ * */ class Gallery { private $MySQL_Host, $MySQL_Database, $MySQL_User, $MySQL_Password, $MySQL_Table; public static function GenerateCSS($folder = "img/",$imgclass = "fotodiv") { foreach(glob($folder."*.{jpg,png,gif,jpeg,ico}", GLOB_BRACE) as $Path) { $Bestand = str_replace($folder, "", $Path);//stip folder $Bestand = str_replace(".", "_", $Bestand);//remove dots to genereate classname $rstring .= ".img_$Bestand:hover + .desc_$Bestand"; $rstring .= "{display: block;} \n"; /*$rstring .= ".desc_$Bestand:hover + .desc_$Bestand"; //unnuset figure out howto code $rstring .= "{display: block;} \n";*/ } return $rstring; } public static function Generate($folder = "img/",$imgclass = "fotodiv") { foreach(glob($folder."*.{jpg,png,gif,jpeg,ico}", GLOB_BRACE) as $Path) { $Bestand = str_replace($folder, "", $Path); $Bestand = str_replace(".", "_", $Bestand); $rstring .= '<div class="'.$imgclass.'">'; $rstring .= '<img class="img_'.$Bestand.'" src="'.$Path.'">'; $rstring .= '<div class="desc_'.$Bestand.'"><p>'.$Bestand.'</p></div></div>';// functie GDescription gebruiken om de beschrijving te krijgen } return $rstring; } /** * * Hieronder niet afgemaakt */ private function GDescription($Path) //private omdat hij alleen binnen de class word gebruikt om de description te vullen voor nu { //$Bestand = str_replace("img/", "", $Path); haal met path uit database $MySQL_Connect = mysqli_connect($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_Database); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($MySQL_Connect,"SELECT * FROM `$MySQL_Table` WHERE File = '$Path'"); $rstring = mysqli_fetch_array($result); mysqli_close($MySQL_Connect); return $rstring['Description']; } } ?>
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
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/Q3Ws6 on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Q3Ws6 on line 17
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/Q3Ws6 on line 17
Process exited with code 255.