Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用wordpress php的strtolower和类似函数_Php_Wordpress_Function_Echo_Str Replace - Fatal编程技术网

使用wordpress php的strtolower和类似函数

使用wordpress php的strtolower和类似函数,php,wordpress,function,echo,str-replace,Php,Wordpress,Function,Echo,Str Replace,您好,我正在试图找出如何使用strolower函数和strtolower+str_replace函数,代码如下- 这是我目前所拥有的,但它不起作用- <?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 ?>

您好,我正在试图找出如何使用strolower函数和strtolower+str_replace函数,代码如下-

这是我目前所拥有的,但它不起作用-

 <?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('custom_field_36',$user->ID)

您最好只吃:

或者将其放入一个变量并响应:


好吧,看来我不需要回去学习基本的PHP语法规则,我自己就可以解决了

万一有人想知道我是怎么做到的-

<?php
      $f_states = get_the_author_meta( 'custom_field_35', $user->ID, true );
$f_pr = get_the_author_meta( 'custom_field_36', $user->ID, true );
?>
<?php Print(strtolower(str_replace(",", "",$f_pr))); ?> <?php Print(strtolower($f_states)); ?>


不能将函数设置为那样的值。您必须应用strtolower和stru替换,然后将结果存储在一个变量中。@Marc B我这样做是因为我尝试了不同的方法,看看是否能让它工作。尝试这样的方法将是cargo cult编程的标志。做一些事情却没有真正理解为什么。@Supericy你能解释一下我是如何做的或提供一个例子吗?@Marc B我对php或函数不太熟悉,所以是的,我只是在尝试代码,看看会发生什么。但我仍然需要知道如何完成这项任务。您是否有任何相关信息或示例可以提供帮助?您好,我尝试使用您的建议并收到此错误-“致命错误:函数名必须是中的字符串…”我的代码就是我在原始问题中输入的代码。我不得不从我的页面中删除代码,因为我不断出错。我基本上想做的是让author元以小写形式输出,另一个函数使其小写并删除逗号。