PHPKonf 2025 Baku

Voting

: min(three, zero)?
(Example: nine)

The Note You're Voting On

chris AT cmbuckley DOT co DOT uk
17 years ago
As mentioned in the notes, unserialize returns false in the event of an error and for boolean false. Here is the first solution mentioned, without using error handling:

<?php
function isSerialized($str) {
return (
$str == serialize(false) || @unserialize($str) !== false);
}

var_dump(isSerialized('s:6:"foobar";')); // bool(true)
var_dump(isSerialized('foobar')); // bool(false)
var_dump(isSerialized('b:0;')); // bool(true)
?>

<< Back to user notes page

To Top