欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

php有多少种占位符,php 占位符问题?

发布时间:2024/9/27 39 豆豆
生活随笔 收集整理的这篇文章主要介绍了 php有多少种占位符,php 占位符问题? 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

为什么我echo出来的东西就是一个%s?而不是我赋值的字符串?

完整代码:

IndexAction.class.php

// 本类由系统自动生成,仅供测试用途

class IndexAction extends Action {

public function index(){

$this->responseMsg();

}

public function responseMsg(){

$postStr="

1348831860

1234567890123456

";

$postObj = simplexml_load_string($postStr);

$fromUsername = $postObj->FromUserName;

//echo $fromUsername;

//echo '111';

$toUsername = $postObj->ToUserName;

$time = time();

$msgType = $postObj->MsgType;

$content = $postObj->Content;

if($content=='tel'){

$indexModel=new IndexModel();

$indexModel->responseText($postObj,$content);

}

}

}

IndexModel.class.php

class IndexModel extends Model{

//回复纯文本

public function responseText($postObj,$content) {

$time=time();

$fromUsername = $postObj->FromUserName;

$toUsername = $postObj->ToUserName;

$textTpl = "

%s

";

echo "textTpl is: ".$textTpl;

$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $content);

// echo $resultStr;

}

}

?>

总结

以上是生活随笔为你收集整理的php有多少种占位符,php 占位符问题?的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。