3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class c_query{ public function query($sqlfind,$rowsPerPage=2,$pageNum=1,$range=2,$order="ASC",$style="grey") { if(isset($_GET['page'])){ $pageNum = $_GET['page'];} $offset = ($pageNum - 1) * $rowsPerPage; $sql = mysql_query("$sqlfind ORDER BY `id` $order LIMIT $offset, $rowsPerPage"); $sql1total = mysql_query("$sqlfind ORDER BY `id` $order"); $numrows = mysql_num_rows($sql1total); $maxPage = ceil($numrows /$rowsPerPage); $self = $_SERVER['PHP_SELF']."?"; $nav = '';if ($numrows > 0){ $first = "<span class=\"pages $style active\">Page: $pageNum of $maxPage</span>"; } if($pageNum > $range+1){$min5 = $pageNum-$range;}else{$min5 = 1;} if($pageNum > 1){for($page = $min5; $page < $pageNum; $page++){$nav .= "&nbsp;<a class=\"pages $style ahref\" href=\"$self"."page=$page\">$page</a>";}} $max5 = $pageNum+$range; if($max5 > $maxPage){$max5 = $maxPage;} for($page = $pageNum; $page <= $max5; $page++){ if ($page == $pageNum){ $nav .= " <span class=\"pages $style active\">$page</span>"; }else{$nav .= "&nbsp;<a class=\"pages $style ahref\" href=\"$self"."page=$page\">$page</a>"; }} if($maxPage == 1){$nav = "";} if ($pageNum > 1){$page = $pageNum - $range-1; if($page < 1){$page = 1;} $prev = " <a class=\"pages $style ahref\" href=\"$self&page=$page\"><</a> "; $first .= " <a class=\"pages $style ahref\" href=\"$self"."page=1\">First</a> "; }else{$prev = '&nbsp;';$first .= '&nbsp;'; } if ($pageNum < $maxPage){$page = $pageNum + $range+1; if($page > $maxPage){$page = $maxPage;} $next = " <a class=\"pages $style ahref\" href=\"$self&page=$page\">></a> ";$last = " <a class=\"pages $style ahref\" href=\"$self"."page=$maxPage\">Last</a> ";}else{$next = '&nbsp;';$last = '&nbsp;';} $this->pages = "<div id=\"pagination\">$first $prev $nav $next $last</div>"; $this->queryarr = $sql; } } $query = new c_query(); $query->query("SELECT * FROM `table`",1,1,1,"ASC","blue circle"); echo "$query->pages <br>"; ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function mysql_query() in /in/DmA0S:6 Stack trace: #0 /in/DmA0S(26): c_query->query('SELECT * FROM `...', 1, 1, 1, 'ASC', 'blue circle') #1 {main} thrown in /in/DmA0S on line 6
Process exited with code 255.
Output for 5.0.0 - 5.6.28
Fatal error: Call to undefined function mysql_query() in /in/DmA0S on line 6
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/DmA0S on line 3
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/DmA0S on line 3
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/DmA0S on line 3
Process exited with code 255.