How is urlencode () used?

Source: Internet
Author: User
I don't seem to be able to use it like this. do you say the fourth line $ name is undefined or something? & amp; lt ;? Php $ name & #039; A & amp; BC & #039; $ nameurlencode ($ name); echo & #039; www. cndn. ccX1.php? Name $ name & #039 ;;? & Amp; gt; I can't seem to be able to use it like this. The fourth line of $ name is undefined or something.
$ Name = 'a & B C'
$ Name = urlencode ($ name );
Echo 'http: // www. cndn. cc/X1.php? Name = $ name ';
?>

Reply content:

I can't seem to be able to use it like this. say the fourth line $ name is undefined or something.
$ Name = 'a & B C'
$ Name = urlencode ($ name );
Echo 'http: // www. cndn. cc/X1.php? Name = $ name ';
?>

1. $ name = 'a & B c' // use A semicolon instead.
2. output variables in the string. double quotation marks are required.

The following code is correct:

$name='A&B C ';$name=urlencode($name);echo "http://www.cndn.cc/X1.php?name=$name";


  

Dude, you missed the semicolon in the second line.

Furthermore, if you want to output the value of $ name in the last line, you cannot use single quotation marks. you must use double quotation marks.


  

Pay more attention to the syntax when writing code later. such low-level errors should not be made.

$ Name = 'a & B C'; $ name = urlencode ($ name); echo "http://www.cndn.cc/X1.php? Name = {$ name} "; echo" http://www.cndn.cc/X1.php? Name = $ name "; // The echo 'http: // www. cndn. cc/X1.php? Name = '. $ name;

// The solution is the semicolon and double quotation marks mentioned above.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.