3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Fibonacci sequence</title> <link rel="stylesheet" type="text/css" href="common.css" /> <style type="text/css"> th { text-align: left; background-color: #999; } th, td { padding: 0.4em; } tr.alt td { background: #ddd; } </style> </head> <body> <h2>Fibonacci sequence using recursion</h2> <table cellspacing="0" border="0" style="width: 20em; border: 1px solid #666;"> <tr> <th>Sequence #</th> <th>Value</th> </tr> <?php $iterations = 10;function fibonacci( $n ) { if ( ( $n == 0 ) || ( $n == 1 ) ) return $n; return fibonacci( $n-2 ) + fibonacci( $n-1 ); } for ( $i=0; $i <= $iterations; $i++ ) { ?> <tr<?php if ( $i % 2 != 0 ) echo ' class="alt"' ?>> <td>F<sub><?php echo $i?></sub></td> <td><?php echo fibonacci( $i )?></td> </tr> <?php } ?> </table> </body> </html>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Fibonacci sequence</title> <link rel="stylesheet" type="text/css" href="common.css" /> <style type="text/css"> th { text-align: left; background-color: #999; } th, td { padding: 0.4em; } tr.alt td { background: #ddd; } </style> </head> <body> <h2>Fibonacci sequence using recursion</h2> <table cellspacing="0" border="0" style="width: 20em; border: 1px solid #666;"> <tr> <th>Sequence #</th> <th>Value</th> </tr> <tr> <td>F<sub>0</sub></td> <td>0</td> </tr> <tr class="alt"> <td>F<sub>1</sub></td> <td>1</td> </tr> <tr> <td>F<sub>2</sub></td> <td>1</td> </tr> <tr class="alt"> <td>F<sub>3</sub></td> <td>2</td> </tr> <tr> <td>F<sub>4</sub></td> <td>3</td> </tr> <tr class="alt"> <td>F<sub>5</sub></td> <td>5</td> </tr> <tr> <td>F<sub>6</sub></td> <td>8</td> </tr> <tr class="alt"> <td>F<sub>7</sub></td> <td>13</td> </tr> <tr> <td>F<sub>8</sub></td> <td>21</td> </tr> <tr class="alt"> <td>F<sub>9</sub></td> <td>34</td> </tr> <tr> <td>F<sub>10</sub></td> <td>55</td> </tr> </table> </body> </html>

preferences:
276.65 ms | 409 KiB | 390 Q