我最近在WordPress代码中更频繁地看到了标记%1$和类似的标记,但我不明白它的含义。这里有一个例子:
sprintf( __( \'%1$s is deprecated. Use %2$s instead.\' ),
有人知道这是什么意思吗?我最近在WordPress代码中更频繁地看到了标记%1$和类似的标记,但我不明白它的含义。这里有一个例子:
sprintf( __( \'%1$s is deprecated. Use %2$s instead.\' ),
有人知道这是什么意思吗?%s
只是字符串的占位符%d
只是一个数字的占位符,因此sprintf的示例如下所示:$variable = sprintf(
\'The %s ran down the %s\', // String with placeholders
\'dog\', // Placed in the first %s placeholder
\'street\' // Placed in the second %s placeholder
);
它将向我们的变量返回一个字符串$variable
:这个dog 沿着street
通过对占位符进行编号,这是一种方便开发人员的方法,可以快速判断以下字符串将放置在何处。它还允许我们重用字符串。让我们以数字占位符为例:
$variable = sprintf(
\'The %1$s ran down the %2$s. The %2$s was made of %3$s\', // String with placeholders
\'dog\', // Will always be used in %1$s placeholder
\'street\', // Will always be used in %2$s placeholder
\'gravel\' // Will always be used in %3$s placeholder
);
它将向我们的变量返回一个字符串$variable
:这个dog 沿着street. 这个street 是由gravel
最后__()
函数让我们翻译传递给它的字符串。通过路过__()
占位符,然后将整个字符串传递给sprintf()
, 我们可以翻译传递给翻译函数的任何内容,从而使字符串和应用程序更加动态。
我已经在这里搜索并尝试了很多东西,但我的问题仍然是“活着”可以设置WP_MEMORY_LIMIT 在默认常量内。php和这个很好,但每次我更新wordpress时,我都必须再次进行此设置。所以我的wp配置。php不会覆盖默认配置中的设置。php。wp配置文件是直接从wordpress自动创建的。我查过了this thread, 我的设置WP_MEMEORY_LIMIT 位于正下方WP_DEBUG 和之前ABSPATH 已定义。$table_prefix = \'hp365_01_\';