3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php <?php $driver = 'mysql'; $database = "dbname=CODINGGROUND"; $dsn = "$driver:host=localhost;unix_socket=/home/cg/mysql/mysql.sock;$database"; $username = 'root'; $password = 'root'; try { $conn = new PDO($dsn, $username, $password); echo "<h2>Database CODINGGROUND Connected</h2>"; }catch(PDOException $e){ echo "<h1>" . $e->getMessage() . "</h1>"; } function multiexplode ($delimiters, $string) { $ready = str_replace($delimiters, $delimiters[0], $string); $launch = explode($delimiters[0], $ready); return $launch; } $text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempus sed ex vel mattis. Etiam a metus ipsum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec efficitur nibh ut quam vestibulum, pellentesque facilisis quam ullamcorper. Vivamus quam justo, finibus nec vulputate ac, molestie ut sem. Sed faucibus, lorem eu ultricies mattis, nulla enim aliquet arcu, at maximus diam mauris vel arcu. Etiam nec dolor at est varius vulputate. Integer laoreet feugiat volutpat. Integer vehicula sapien sed rutrum mattis. Curabitur eu metus in magna pulvinar condimentum. Integer id ligula at sem tincidunt consectetur vitae vitae turpis. Mauris volutpat nec leo vel luctus. Sed mauris erat, faucibus eget porta nec, ullamcorper eget libero. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam porta, metus a facilisis volutpat, enim augue condimentum eros, at laoreet dui purus ac lectus. Morbi feugiat gravida mauris vitae pulvinar. Nam quis ligula pellentesque, varius enim vitae, varius turpis. In vitae sollicitudin leo, sed placerat neque. Donec eget tortor quis libero condimentum iaculis. Maecenas consequat arcu mauris, vel euismod massa dictum a. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla in augue vel nisl pellentesque interdum. Curabitur vulputate non magna id rutrum. Ut finibus nisi nec velit semper scelerisque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos."; $word = "id"; $new_word = "<h1>BIGD</h1>"; $textarr = multiexplode(array(" ",".",",",":",";","!","?"), $text); for ($i=0; $i<count($textarr); $i++){ if (strcasecmp($textarr[$i],$word)==0){ $textarr[$i] = $new_word; } } $new_text = implode(" ",$textarr); echo $new_text; $sql = 'SELECT * FROM users'; $sql = 'INSERT INTO res1(words) VALUES('".$new_text."')'; $stmt = $conn->prepare($sql); $stmt->execute(); echo "<table style='width:100%'>"; while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ echo "<tr>"; foreach($row as $value) { echo sprintf("<td>%s</td>", $value); } echo "</tr>"; } echo "</table>"; ?>
Output for 7.0.0
Parse error: syntax error, unexpected '<', expecting end of file in /in/cb9s5 on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.6.16
Parse error: syntax error, unexpected '<' in /in/cb9s5 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '<' in /in/cb9s5 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/cb9s5 on line 3
Process exited with code 255.