php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54287 Notation of the placeholders seems wrong
Submitted: 2011-03-17 08:03 UTC Modified: 2011-03-17 08:21 UTC
From: accounts at rgloyer dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: accounts at rgloyer dot de
New email:
PHP Version: OS:

 

 [2011-03-17 08:03 UTC] accounts at rgloyer dot de
Description:
------------
---
From manual page: http://www.php.net/function.sprintf#Parameters
---
From the manual page:

Example #3 Argument swapping
<?php
$format = 'The %2$s contains %1$d monkeys';
printf($format, $num, $location);
?>

This doesn't work. I get the error: undefined variable

It works if i write: %2\$s and %1\$d


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-17 08:21 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2011-03-17 08:21 UTC] aharvey@php.net
The examples are (intentionally) incomplete: if you define $num and
$location, you won't get the warnings.
 [2011-03-17 09:14 UTC] carsten_sttgt at gmx dot de
@aharvey
> The examples are (intentionally) incomplete:

What's the sense of a /intentionally/ incomplete example?


In my opinion it's just a wrong example and thus a documentation problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 23:01:29 2024 UTC