PHP equivalent of Python's `str.format` method?

后端 未结 3 2191
难免孤独
难免孤独 2021-02-19 21:06

Is there an equivalent of Python str.format in PHP?

In Python:

\"my {} {} cat\".format(\"red\", \"fat\")

All I see I can d

3条回答
  •  情书的邮戳
    2021-02-19 21:26

    sprintf is the closest thing. It's the old-style Python string formatting:

    sprintf("my %s %s cat", "red", "fat")
    

提交回复
热议问题