English 中文(简体)
PHP: 显示使用功能的信息而不使用对应信息
原标题:PHP : Display a message using a function without using echo

这里的职能简单。

function hello($name) {
  $message =  Hello  .$name.  How are you feeling today? ;
  return $message;
}

And as you know, when I execute this function it returns a message.

<?php
  echo hello(Stackoverflow);
?>

产出:

Hello Stackoverflow How are you feeling today?

如果不使用回馈(至少在这里)来显示这一信息,是否有办法。

like <?php hello(Stackoverflow); ?> and it should return the message.

最佳回答

如果情况如此,您的职能应当有<条码>。

function hello($name) {
  $message =  Hello  .$name.  How are you feeling today? ;
  echo $message;
}
问题回答

There are many ways to display something. printf is very useful in this case.

<?php
function hello($name){
   printf( Hello %s How are you feeling today? , $name);
}
?>

如果在<代码>和t上贴有短标签;?= hello(Stackoverflow )?>? 但它不赞成使用否决权。

function hello($name) {
  $message =  Hello  .$name.  How are you feeling today? ;
  echo $message;
}

http://php.net/manual/en/Function.error-log.php“rel=“nofollow”http://php.net/manual/en/Function.error-log.php。

<?= hello( String ) ?>




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签