1

I'm trying to get the cureent url and send that through in a link and I'm stuck. The link displays but it's missing the url that I want to include (content in the code sample here)

'href' => ( "http://chart.apis.google.com/chart?cht=qr&chs=300x300&choe=UTF-8&chld=H&chl='.$content .'")

3 Answers 3

3

You're mixing single and double quotes. Try this:

'href' => ( "http://chart.apis.google.com/chart?cht=qr&chs=300x300&choe=UTF-8&chld=H&chl=".rawurlencode($content))
Sign up to request clarification or add additional context in comments.

Comments

3

First: use urlencode:

$content = urlencode($content);

Second: replace your single quote with double quote.

Comments

1

Your quotes aren't correct:

'href' => ( "http://chart.apis.google.com/chart?cht=qr&chs=300x300&choe=UTF-8&chld=H&chl=".$content)

You should also use urlencode() and urldecode() to ensure the $content variable is properly formatted

Edit Try this then:

$currentUrl = rawurlencode($_SERVER['PATH_INFO']);
$newUrl = "http://chart.apis.google.com/chart?cht=qr&chs=300x300&choe=UTF-8&chld=H&chl=";

header("Location: $newUrl.$currentUrl");

//Not sure if path_info will always contain the full url but there are lots of functions on the web to grab the current url that you can google for.

2 Comments

Your original post looks like a fragment of an array. should be $arr = array( 'href' => ( "chart.apis.google.com/…) ); Then you would access that variable as $arr['href'] so if you wanted to redirect to that url it would be header('Location: '.$arr['href']);
Thanks - your first solution was fine, I had the $content set in the wrong place. Thanks for your efforts. D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.