Help with Return value not showing '

Hi there,

I can’t seem to work this out.

The return value seems to ommit the ’ in the script. The code is as follows:

return '<script type="text/javascript">a('.$url.', '.$b.', '.$s.');</script>';

The value that is being returned is:

I need it to return the values with a ’ eg:

Please help.

This is a basic HTML issue not really PHP, but, we can help you…

The problem is inside and outside quotes. You can NOT use single quotes INSIDE single quotes unless you “escape” them. The easiest way is just change the INSIDE single quotes to double quotes. All done.

OR, if you want the single quotes to show up in the results, you need to “escape” them. (Using ‘/’)
So, ‘.$url.’ becomes /’.$url./’

Maybe this will explain it: your code:
return ‘’;
is REALLY this code:
return ‘’;
**** Note the single quotes are what you started and ended with and you can’t use them in between with the escape.

Hope that helps…

Thanks for your prompt reply. I managed to get the code working based on the information you provided. However, I had to use ’ instead of /’

Using ’ did not work.

Try it this way:

[php]
return “”;
[/php]

Remember, if something has ’ or ", another will cause the program to think that it is the end of the statement. You must escape characters like so: " or ’

Another idea is to use opposite quotes, like:
[php]
echo ’ “Stuff” ';
echo " ‘Stuff’ ";
[/php]

Oops sorry, thought this was a PHP question, but the concept may still work. :wink:

Yes, it is a PHP question and HTML question!

And, sorry for the wrong slash, I was typing while thinking and I always seem to mix up the slashes…
Sorry again for that confusion… Glad you solved it. Will mark it so…

Sponsor our Newsletter | Privacy Policy | Terms of Service