3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*** * EN: Code samples written in PHP 5 by Louis Fontaine, 2016 * Three simple code samples + unit tests, allowed to be distributed by Treffer Uitzendbureau. For ease * of distribution, all code is contained in a single file. * Sample one outputs HTML code for a very simple web page using some dynamic content. * Sample two ... * Sample three consists of excerpts from code currently in production at a former client, used to * geocode zipcodes by accessing a 3rd party web service and estimate the distance to a user's location. * * NL: Voorbeeldcode in PHP 5 door Louis Fontaine, 2016 * Drie simpele stukken voorbeeldcode + unit tests, uit te geven door Treffer Uitzendbureau. Om de code * makkelijker te kunnen verspreiden, is alles samengevoegd in één bestand. * Voorbeeld één geeft als output HTML code van een simpele webpagina met wat dynamische content. * Voorbeeld twee ... * Voorbeeld drie bestaat uit fragmenten van code die momenteel in productie zijn bij een voormalige cliënt * met als functie het geocoderen van postcodes met behulp van een 3rd party webservice en het schatten van * afstanden tot de huidige locatie van de gebruiker. ***/ function runAllSamples(){ sample1(); runAllUnitTests(); } function sample1(){ $pageWriter = new PageWriter(); $pageWriter->write(); } class PageWriter{ private $useRandom = false; function __construct($testMode = false){ $useRandom = !$testMode; } function write(){ ?> <?php } } function runAllUnitTests(){ $pageWriter = new PageWriter(false); $success = compareWebPageHTML($pageWriter.write()); echo 'Unit test PageWriter (sample one): ' . $success ? 'success' : 'failed'; } runAllSamples(); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function compareWebPageHTML() in /in/c9mG8:47 Stack trace: #0 /in/c9mG8(23): runAllUnitTests() #1 /in/c9mG8(51): runAllSamples() #2 {main} thrown in /in/c9mG8 on line 47
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
52.69 ms | 401 KiB | 8 Q