我刚开始编码,自己无法解决这个问题。请帮忙。
wordpress 中的示例
<input type="text" name="old" value="<?php echo home_url(); ?>" />
打印-https://example.com
更改打印值=http://example.net
在没有Jquery的情况下,在PHP中调用home_url后,是否可以更改打印值?
谢谢!
内联使用str_replace
函数;home_url()
将值返回给str_replace
作为输入,然后根据需要,此函数将com
替换为net
。
<input type="text" name="old" value="<?php echo str_replace('com','net',home_url()); ?>" />
我的最终答案
<input type="text" name="old" value="
<?php
$letters = array('https', 'com');
$fruit = array('http', 'net');
$output = str_replace($letters, $fruit, home_url());
echo $output; ?>" style="width:600px;" />