Solved

PHP string issue

Posted on 2016-11-22
5
18 Views
Last Modified: 2016-11-22
I am setting a value but it is being changed. Not sure why.

$field .= '&timestamp_unix=#{timestamp_unix}';

Open in new window


It is outputted as "×tamp_unix=#{timestamp_unix}" instead of "&timestamp_unix=#{timestamp_unix}"

If I put something infront of "time" it is outputted correctly with the text in front. If I use str_replace to try to format it the way I want it reverts to the same issue.
0
Comment
Question by:Robert Saylor
  • 3
  • 2
5 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41897742
&times is the character entity for the little X multiplication sign.  It's working correctly.  Please look at it in the browser's "view source" window and tell us what you see, thanks.
0
 

Author Comment

by:Robert Saylor
ID: 41897752
how can I make "&times" display "&times" instead of "x" ?

I understand the issue now. ASCII ugg
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41897764
What does it show in the browser "view source?"

What is the use-case that is in play here?  Is this a template engine for a framework?

This will fix the browser display, but I'm not sure that's what you really want?
https://iconoun.com/demo/temp_robert_saylor.php
<?php // demo/temp_robert_saylor.php
/**
 * https://www.experts-exchange.com/questions/28984771/PHP-string-issue.html
 */
error_reporting(E_ALL);
echo '<pre>';

$field = NULL;
$field .= '&amp;' . 'timestamp_unix=#{timestamp_unix}';
echo $field;

Open in new window

0
 

Author Closing Comment

by:Robert Saylor
ID: 41897874
I will just wrap it in a text box. Was building a configuration system for one of our advertising systems. You identified the ASCII value and that is what was going on. I completely forgot about those. Sadly I thought the ASCII value had to end with the ; but I guess not.
0
 

Author Comment

by:Robert Saylor
ID: 41897883
FYI the wrapper did not work. The &amp; solution did the trick.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now