Solved

PHP sprintf

Posted on 2013-01-31
8
276 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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 82

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 42

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 18

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
 
LVL 18

Expert Comment

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

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

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

I need <b>

The less than symbol is the issue.
0
 
LVL 42

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 42

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

706 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

15 Experts available now in Live!

Get 1:1 Help Now