PHP & HTML:如何在连接的 PHP 字符串变量中包含.php


PHP & HTML: How to include .php in concatenated PHP string var

我正在尝试做的事情的例子:

<?php
 $html_element = '<form><label>country</label><select>'.include_once("country_list.php").'</select></form>';
?>

我已经尝试了上述和以下方法:

<?php
 $html_element = '<form><label>country</label><select><?php include_once("country_list.php"); ?></select></form>';
?>

当然,"$html_element"稍后会在某个div中回显。那么我怎样才能在这个 php 字符串变量中包含"country_list.php"以便它正确拉取呢?

如果要

包含数据,无论它是哪种文件类型,请执行以下操作:

<?php
 $html_element = '<form><label>country</label><select>'.file_get_contents("country_list.php").'</select></form>';
?>