Php concatenating url with variable
6 answers
Try the following:
$url = "www.example.com/$link";
When the string is in double quotes , you can put variables in it. The variable value will be inserted into the string.
You can also use concatenation to join two strings:
$url = "www.example.com/" . $link;
+11
source to share
Hate to duplicate the answer, but use single quotes to prevent the parser from looking for variables in double quotes. A few minutes faster.
$url = 'www.example.com/' . $link;
EDIT: And yes .. where performance really mattered in the ajax backend I wrote replacing all my interpolation with concatenation gave me 10ms in response to response time. The script provided was 50k.
+1
source to share