Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 759263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:34:30+00:00 2026-05-14T15:34:30+00:00

I am creating a web app that accepts input of news items (title, article,

  • 0

I am creating a web app that accepts input of news items (title, article, url). It has a page news.php which creates a summary of all news items inputted for specified dates, like so:

News
4/25/2010

Title 1
[URL 1]
Article 1

Title 2
[URL 2]
Article 2

and so on…

I have two other pages, namely preview.php and send.php , both of which call news.php through a file_get_contents() call.

Everything works fine except when the URL contains spaces. During Preview, the urls get opened (FF: spaces are spaces, Chrome: spaces are %20). However, during Send, when received as emails, the urls don’t get opened, because the spaces are converted into + signs.

For example:

  1. Preview in FF: http://www.example.com/this is the
    link.html
  2. Preview in Chrome: http://www.example.com/this%20is%20the%20link.html
  3. Viewed as email in both browsers: http://www.example.com/this+is+the+link.html

Only #3 doesn’t work (link doesn’t get opened).

Why are the spaces in the urls correct (spaces or %20) when previewed, but incorrect (+) when received in the emails, when in fact, the same page is generated by the same news.php?

Any help appreciated 🙂


EDIT:

preview.php:

$HTML_version = file_get_contents('news.php');
echo $HTML_version;

send.php

$HTML_version = file_get_contents('news.php');
$body = "$notice_text

--$mime_boundary
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

$TEXT_version

--$mime_boundary
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

$HTML_version

--$mime_boundary--";
//some other code here to send the email

news.php:

<a href="<?php echo $url ?>">attachment</a>
//the $url there contains spaces
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:34:30+00:00Added an answer on May 14, 2026 at 3:34 pm

    What mail client are you using? Mail clients’ handling of HTML is subject to extreme limitations and bugs.

    <a href="<?php echo $url ?>">attachment</a>
    //the $url there contains spaces
    

    URLs don’t contain spaces, by definition. If you include a space in a link in HTML:

    <a href="x y.z">
    

    the browser will typically fix your error, by encoding to x%20y.z. However this is not a standardised behaviour and you should not rely on it. It is, I suppose, possible that some dodgy mail client could be misguidedly ‘fixing’ it up to x+y.z instead, which wouldn’t work because + in the path part of a URL does not mean a space.

    Use rawurlencode() for URL-encoding. With this function, spaces are converted to %20, which is appropriate for URL path-parts and query strings. PHP’s misleadingly-named urlencode() function encodes to + instead, which is only appropriate in form data in the query string.

    You also need to use htmlspecialchars() any time you output a string to HTML.

    $name= 'this is the link';
    $url= 'http://www.example.com/'.rawurlencode($name).'.html';
    
    <a href="<?php echo htmlspecialchars($url); ?>">link</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an app that needs to be accessed by both a web front
I'm creating a web app that requires registration/authentication, and I'm considering using an email
I am creating a web app that uses Rails built-in helper functions to add
I'm creating a web application for work where the user has to enter the
I'm involved in creating a web based business solution. The idea is that the
I am writing a web app using TurboGears, and in that app the users
I'm building a small web app that allows users to list their goals. I
When creating web parts for Sharepoint, is it better to create an actual web
When creating web pages how do we achieve a consistent font size across browsers.
Is there a way when creating web services to specify the types to use?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.