• 跳至主要导航
  • 跳到主要内容
  • 跳到主要侧边栏

WP站点

2665

原始创世纪教程和5000多个保证代码

片段

  • 支持
  • 通讯
  • 影片
  • 登录

高级会员? -请求自定义代码

冲刺

冲刺 类似于 打印 但是用于返回结果作为a的值 变量 供以后使用而不是立即输出。

这里’您可以在子主题功能文件中测试的区别。

冲刺
add_action('loop_start','sprintf_example' );
function 冲刺_example() {		
$output = 冲刺('%s World', 'Hello' ); 
echo $output;
}
打印
add_action('loop_start','printf_test' );
function 打印_test() {		
	printf('%s World', 'Hello' ); 
}

Both code snippets produce exactly the same result. The only difference is 冲刺 returns the value for the 变量 and 打印 outputs directly.

You can also write the code using 冲刺 like this:

add_action('loop_start','sprintf_example1' );
function 冲刺_example1() {
$text = "Hello";		
$output = 冲刺('%s World', $text ); 
echo $output;
}

和这个:

add_action('genesis_after_header','sprintf_example2' );
function 冲刺_example2() {
    $link = get_permalink();
    $text = "Hello";		
    $output = 冲刺('%s World', $text ); 
printf( '<a href="%s">' . $output . '</a>', $link );
}

或这个:

add_action('wp_head','sprintf_example3' );
function 冲刺_example3() {
    $link = get_permalink();
    $text = "sprintf";		
    $output = 冲刺('%s Example', $text ); 
printf( '<a href="%s">%s</a>', $link, $output );
}

相关的PHP代码

  • 打印
  • 变量
  • 使用sprintf的12个代码示例& 冲刺

PHP函数

读者互动

发表评论 取消回复

你一定是 登录 发表评论。

主侧边栏

PHP代码

template_include

get_body_class

如果别的

数组

class_exists

前言

冲刺

add_action

打印

变量

广告 · WPEngine · 创世记 · 登录

  • 高级会员的工作方式
  • 报名
  • 支持
  • 订阅详细信息/发票
  • 标记教程
  • 访问下载问题

    <font class="WeqnuDP"><col id="K5jrkFC" class="KGg90Hq"></col></font>




    • <legend id="P58aLsW" class="PJThDIY"><applet id="jgqxzug"></applet></legend>
      <p></p>



          <dt class="PfC0lqs"><del id="EB5OCD1" class="E7K95Tq"><textarea id="DlzkvI6" class="DE8DpNE"></textarea></del></dt>