PHP 需要并包含 GET

2022-01-04 00:00:00 get php require-once

我想要一个文件,但也通过 url 传递 GET 变量,但是当我写:

I would like to require a file but also pass GET variables through the url, but when I write:

<?php
   require_once("myfile.php?name=savagewood");
?>

我收到一个致命错误.我将如何以不同的方式完成此功能,以免出现致命错误?

I get a fatal error. How would I accomplish this functionality in a different way, such that I don't get a fatal error?

推荐答案

变量将正常可用,您不必像这样传递.

variables will be available as normal you do not have to pass like this.

$name='savagewood';
require_once("myfile.php");

$name 将在 myfile.php

相关文章