Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

problem in Encoding the special character & for getting result in php

Featured Replies

i'm display product information from file by there name

So in some products name included with special characters specially ' & 'etc..

so for example : here is the url mysite.com/index.php?s=html & php so its showing html only in echo

i'm using $_REQUEST['s']; for getting url

here is the code for encode i used




<?php
$text = $_REQUEST['s'];
echo rawurlencode($text);
?>


but its not working with $_request its displaying only Html


but when i used simple text its work eg..




<?php
$text = ('html & php');
echo rawurlencode($text);
?>


so now its work and echo came html%20%26%20php and thats what i want

please help me to solve that $_REQUEST thing what should i do with that


thanks in advanced

it is because you are using & in the url this acts as a seperator, try using %26 inplace of the &

 

i.e. mysite.com/index.php?s=html %26 php

  • Author

it is because you are using & in the url this acts as a seperator, try using %26 inplace of the &

 

i.e. mysite.com/index.php?s=html %26 php

 

i cannot change the url because i'm getting link data from xml file feed from an online server

product name html & php in xml so its must be xml & php for showing this product other information eg. details and price ....

 

so i cannot change the name or change the url ...

is there any other solution ??

What's probably happening is:

 

$_GET['s'] = html

$_GET['php'] = ""

 

If you want to grab if it's HTML and php and you definitely can't change the URL then your going to have to hack it around and do something like:

 

If(isset($_GET['php']) && $_GET['s'] == "html") {

$s = "html&php";

}

 

Then use $s and rawurlencode it.

 

Good luck!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.