Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions htmlspecialchars.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
// htmlspecialchars

/*
Convert special characters to HTML entities
e.g. :
"<" convert to "&lt;"
">" convert to "&gt;"
...
*/
$str = "The word <b>text</b> is bold";
echo htmlspecialchars($str);
// HTML output will be "The word &lt;b&gt;text&lt;/&gt; is bold"

$str = "My name is 'Ali'";
echo htmlspecialchars($str);

$str = "What is decrement & increment ?";
echo htmlspecialchars($str);
14 changes: 14 additions & 0 deletions stripslashes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
// stripslashes

/*
# Remove backslashes
This function can be use for clean data received
from user.
*/
$str = "Hello \ my name \ is Ali";
var_dump(stripslashes($str));

// and can be use for ignore escape sequences
$str = "Wellcome \n This is world";
var_dump(stripslashes($str));