In Python you can do this:

print '%(language)s has %(#)03d quote types.' % {'language': "Python", "#": 2}

to format strings with named parameters.

Does anyone know if PHP (5?) supports this sort of functionality?

I know there is the sprintf function; and that it allows numbered parameters; and there is the vsprintf function which allows the arguments to be an array and (I think) allows numbered parameters in the format string as well.

But can we use named parameters?

PS. If anyone can confidently say "no", please do!

    But can we use named parameters?

    PS. If anyone can confidently say "no", please do!

    No, though in the case of database prepared statements the PDO extension allows for named parameters.

      Cheers.

      I'll do me own with regexp or something....

        Write a Reply...