Php url url in url parameter

I am developing facebook / myspace sharing buttons. The Facebook link links to the URL of my website, but I need to pass additional parameters to my URL along with the parameters passed to facebook. Here is my example:

http://www.facebook.com/share.php?t=MyCompany&u=http://foobar.com/test7.php?Share=161&FbShare=Facebook28

Do I need to hide something inside the "u" parameter?

+3
source share
2 answers

You must be able to (http://php.net/manual/en/function.urlencode.php).

$url = 'http://www.facebook.com/share.php?t=MyCompany&u='.urlencode('http://foobar.com/test7.php?Share=161&FbShare=Facebook28');
+8
source

You need to use urlencodein the parameter u, which will cause your URL to look like this:

http://www.facebook.com/share.php?t=MyCompany&u=http%3A%2F%2Ffoobar.com%2Ftest7.php%3FShare%3D161%26FbShare%3DFacebook28

+2
source

Source: https://habr.com/ru/post/1786027/


All Articles