【发布时间】:2013-01-10 16:27:13
【问题描述】:
您好,我想通过以下代码了解如何使用 strlower 函数和 strtolower + str_replace 函数 - <?php echo get_the_author_meta('custom_field_35', $user->ID); ?>
这是我目前所拥有的,但它不起作用 -
<?php
$str = "echo get_the_author_meta('custom_field_35', $user->ID);";
$str = strtolower($str);
echo $str; // Prints mary had a little lamb and she loved it so
?>
<?php $get_the_author_meta('custom_field_36', $user->ID) = strtolower(str_replace(",", "",$get_the_author_meta('custom_field_35', $user->ID))); ?>
如何将 strtolower 和 str_replace 与 get_the_author_meta 一起使用?
【问题讨论】:
-
您不能将函数设置为这样的值。您必须应用 strtolower 和 str_replace,然后将结果存储在变量中。
-
@Marc B 我之所以这样,是因为我尝试了不同的方法,看看能否让它发挥作用。
-
尝试这样的事情将是货物崇拜编程的标志。在没有真正理解原因的情况下做事。
-
@Supericy 你能解释一下我该怎么做或提供一个例子吗?
-
@Marc B 我对 php 或函数不太熟悉,所以是的,我只是在尝试该代码以查看会发生什么。不过,我仍然需要知道如何完成这项任务。您有任何相关信息或示例可以提供帮助吗?
标签: php wordpress function echo str-replace