Solved

PHP sprintf

Posted on 2013-01-31
8
287 Views
Last Modified: 2013-01-31
sprintf('"%s" <%s> (%s) [%s]', a, b, c, d);

will not display <%s>

I get "a" (c) [d] not "a" <b> (c) [d]

do I need some escape character or something?
0
Comment
Question by:mosemadl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38840935
Yes, all the options for use in sprintf() are on this page: http://www.php.net/manual/en/function.sprintf.php  To actually display a '%', you need two of them '%%'.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 38840985
If you're outputting this in HTML you won't see the bit between <> because your page will think it's an HTML tag. View the source of your page and you'll see it, but to render the < and > in HTML you need to use the HTML entities &lt; and &gt;

sprintf('"%s" &lt;%s%gt; (%s) [%s]', a, b, c, d);

Open in new window

0
 
LVL 19

Accepted Solution

by:
Greg Alexander earned 500 total points
ID: 38840994
Just a thought

<?= sprintf('"%s" &lt;%s&gt; (%s) [%s]', a, b, c, d); ?>

Open in new window

0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 19

Expert Comment

by:Greg Alexander
ID: 38841000
Sorry, didn't see that... don't give me points ;)
0
 

Author Comment

by:mosemadl
ID: 38841002
I don't need %

I need <b>

The less than symbol is the issue.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 38841009
@mosemadl - have you just cross-posted or did you miss my post completely?
0
 

Author Closing Comment

by:mosemadl
ID: 38841037
Sorry galexander07. That's exactly it.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 38841045
I seem to be having another invisible day :/
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

617 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