WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does the $GLOBALS['s'] variable contain? It looks like an empty array, but what would it normally hold?

I've encountered it in a tutorial: The WordPress Theme: Single Post, Post Attachment, & 404 Templates, it mentions a long string that gets passed to a printf function call.

The string looks something like this:


$entry_utility = <<<LONGSTR
This entry was posted in %1{$s}%2{$s}.
Bookmark the <a href="%3{$s}" title="Permalink to %4{$s}" rel="bookmark">permalink</a>.
Follow any comments here with the
<a href="%5{$s}" title="Comments RSS to %4{$s}" rel="alternate" type="application/rss+xml">RSS feed for this post</a>.


NOTE: I've wrapped the long string from the tutorial inside a HEREDOC string instead, it was too hard to follow on the single line.

I've wrapped the $s variables in curly-brackets in case heredocs couldn't interpret them correctly.

share|improve this question
up vote 2 down vote accepted

It's not a global variable; in fact it's not a variable at all. It's just placeholder within the sprintf() function. Take a look at the sprintf PHP function documentation.

In the example you cite, the author is using the 'argument swapping' placeholder syntax: %n$t where %n is the placeholder number that corresponds to the argument order (eg: %1, %2 etc) and $t is the type indicator, where 't' is one of 's', 'd', 'f' etc (eg: $s, $d etc). Put them together and you get %1$s %2$d etc.

share|improve this answer
Thanks! Good thing to note too, because I was treating it as a variable, it didn't function properly for the sprintf / printf method. Once I've wrapped the string back into single-quotes (which would prevent the variables from converting to strings, I think), it worked fine! – bigp Oct 28 '11 at 17:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.