MENU
URL
urlencode($s) returns an encoded string by replacing in $s all non-alphanumeric characters (except -_.) with a % sign followed by two hex digits, and all spaces by a + sign. This allows data to be passed along with the URL using the GET method. urldecode($s) decodes any %## encoding in the string $s. + signs are decoded to a space character.rawurlencode($s) is similar to urlencode($s) except that ~ signs are not encoded and spaces are encoded as %##. rawurldecode($s) is similar to urldecode($s) except that + signs are not decoded.
base64_encode($s) encodes $s with MIME base64 to make binary data survive transport through transport layers that are not 8-bit clean. base64_ decode($s) is the reverse of base64_ encode($s).
RESETRUNFULL
<?php
echo "<pre>";
$test = ' -_.~+!@#$%^&';
echo urlencode($test)."\n";
echo rawurlencode($test)."\n";
echo base64_encode($test);
echo "</pre>";
?>
PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER,PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT, a string is returned instead, and the string contains just the specified component.
<?php
echo "<pre>";
print_r(parse_url('http://username:password@hostname/path?arg=value#anchor'));
echo "</pre>";
?>
Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value [fragment] => anchor )
<?php
echo "<pre>";
print_r(get_headers("http://www.google.com",1));
echo "</pre>";
?>
Array ( [0] => HTTP/1.0 302 Found [Location] => http://www.google.com.my/?gws_rd=cr&ei=27FPU-S7O-fniAf4v4GoCQ [Cache-Control] => Array ( [0] => private [1] => private, max-age=0 ) [Content-Type] => Array ( [0] => text/html; charset=UTF-8 [1] => text/html; charset=ISO-8859-1 ) [Set-Cookie] => Array ( [0] => PREF=ID=d115201d75f3707f:FF=0:TM=1397731803:LM=1397731803:S=IiTOX1VG8tEZBzxv; expires=Sat, 16-Apr-2016 10:50:03 GMT; path=/; domain=.google.com [1] => NID=67=T_q3Tm11ZZXK6PSDi2QoPpzfQ1r8-rged9RopxpI5d1ikLo8-RpjczHHS4QtVhbxL8r_XHkrVb2RZlFduHmcKtkDxyVM4GQa3j1LcKLLlM9h9-6COnFpHAEZ5Yv7y1Au; expires=Fri, 17-Oct-2014 10:50:03 GMT; path=/; domain=.google.com; HttpOnly [2] => PREF=ID=92c098fcba592628:FF=0:TM=1397731804:LM=1397731804:S=MI0uB5GJFK7ZZ0-w; expires=Sat, 16-Apr-2016 10:50:04 GMT; path=/; domain=.google.com.my [3] => NID=67=PNjAby1rLsDXZwsY0c9DKEKLw1N9aAZblB9KoOFiUpZZq0Ktg3yfczdeu4YsoX2p2LwWYYk-qxKIl6PIuppc8VHzCnrwMzyL1GAVbM7zc5MUMY0xTRiCHTUhLZYOJbfW; expires=Fri, 17-Oct-2014 10:50:04 GMT; path=/; domain=.google.com.my; HttpOnly ) [P3P] => Array ( [0] => CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." [1] => CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." ) [Date] => Array ( [0] => Thu, 17 Apr 2014 10:50:03 GMT [1] => Thu, 17 Apr 2014 10:50:04 GMT ) [Server] => Array ( [0] => gws [1] => gws ) [Content-Length] => 262 [X-XSS-Protection] => Array ( [0] => 1; mode=block [1] => 1; mode=block ) [X-Frame-Options] => Array ( [0] => SAMEORIGIN [1] => SAMEORIGIN ) [Alternate-Protocol] => Array ( [0] => 80:quic [1] => 80:quic ) [1] => HTTP/1.0 200 OK [Expires] => -1 )
<?php
echo "<pre>";
print_r(get_meta_tags('test.html'));
echo "</pre>";
?>
<html>
<head>
<title>Test Page</title>
<meta name="author" content="Lip Phang"/>
<meta name="keywords" content="Advanced PHP"/>
<meta name="DESCRIPTION" content="URL Functions"/>
</head>
<body>
Hello
</body>
</html>
Array ( [author] => Lip Phang [keywords] => Advanced PHP [description] => URL Functions )
<?php
$arr = ['a'=>1, 'b'=>2, 3];
echo http_build_query($arr,'num')."<br/>";
class O{
private $a=1;
public $b=2;
}
$obj = new O;
echo http_build_query($obj);
?>
a=1&b=2&num0=3 b=2