Created
August 14, 2020 13:50
-
-
Save azwan082/2b1a20b9b293b1937e6e6dc6849959c5 to your computer and use it in GitHub Desktop.
Simple PHP script to test for validity of serialized values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $unserialized = null; ?> | |
<h1><a href="test_serialize.php">Test PHP unserialize</a></h1> | |
<form action="test_serialize.php" method="post"> | |
<p> | |
Unserialize: <?php | |
if (isset($_POST['v'])) { | |
$v = unserialize($_POST['v']); | |
if ($v) { | |
$unserialized = $v; | |
echo '<span style="color:green">Success</span>'; | |
} | |
} ?> | |
</p> | |
<p> | |
<textarea name="v" style="width:800px;height:300px;"><?php if (isset($_POST['v'])) { echo htmlentities(trim($_POST['v'])); } ?></textarea> | |
</p> | |
<p> | |
Length: <?php if (isset($_POST['l'])) { echo strlen(trim($_POST['l'])); } ?> | |
</p> | |
<p> | |
<textarea name="l" style="width:800px;height:150px;"><?php if (isset($_POST['l'])) { echo htmlentities(trim($_POST['l'])); } ?></textarea> | |
</p> | |
<p><button type="submit">Submit</button></p> | |
<?php if ($unserialized) { echo '<p>Unserialized: <pre>'; echo var_export($unserialized, true); echo '</pre></p>'; } ?> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment