在输入标记(文本字段)中执行PHP Echo

AlG*_*laf 2 html php

我在php脚本中使用一个函数来返回一个包含值的文本字段.从变量中检索此值.我怎样才能做到这一点?

这是我尝试使用的代码,但它没有用.

function display_name()
{   
    return '<input type="text" maxlength="50" readonly="readonly" value=" '. $current_user->display_name .'" name="CreatedBy" style="width:100%">';
}
Run Code Online (Sandbox Code Playgroud)

Dan*_*Dan 5

通过将函数作为参数处理.

function display_name($current_user)
{   
    return '<input type="text" maxlength="50" readonly="readonly" value=" '. $current_user->display_name .'" name="CreatedBy" style="width:100%">';
}
Run Code Online (Sandbox Code Playgroud)

然后称之为

display_name($current_user);
Run Code Online (Sandbox Code Playgroud)