Demo entry 5637776

ewgwerg

   

Submitted by anonymous on Jul 06, 2016 at 09:28
Language: PHP. Code size: 238 Bytes.

<?php

function say(?string $msg) {
    if ($msg) {
        echo $msg;
    }
}
 
say('hello'); // ok -- prints hello
say(null); // ok -- does not print
say(); // error -- missing parameter
say(new stdclass); //error -- bad type

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).