note 68153 deleted from wrappers by nlopess
| From: | nlopess@php.net | Date: | Sat, 15 Jul 2006 16:54:00 +0000 |
| Subject: | note 68153 deleted from wrappers by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-114806@lists.php.net to get a copy of this message | ||
Note Submitter: groolot at groolot dot net
Reason: useless
----
#!/usr/bin/php
#
# This script allow you to urlencode a string given to it
# by a pipe.
#
# If its name is : my_script.php (755)
# you can invoke it by :
# prompt:~$ echo "Does it work ?" | my_script.php
#
# and it will return :
#
# Does+it+work+%3F
#
#
<?php
// Opening input stream
$my_stdin = fopen("php://stdin", 'r');
// Stream reading until end of line
$my_string = fgets($my_stdin);
// Return the string urlencoded without the end of line
$my_stdout = fopen("php://stdout", 'w');
fwrite($my_stdout, urlencode(substr($my_string, 0, strlen($my_string) - 1)));
?>