gpt4 book ai didi

php - 如何从地址栏调用 php 函数?

转载 作者:行者123 更新时间:2023-12-05 08:17:36 25 4
gpt4 key购买 nike

我如何从地址栏调用我的 php 文件中声明的函数?我已经尝试将函数名称附加到站点地址,但它没有调用该函数..

http://myWebSite.com/myFile.php?writeMessage

我的文件.php:

<?php
/* Defining a PHP Function */
function writeMessage()
{
echo "You are really a nice person, Have a nice time!";
}
/* Calling a PHP Function */
writeMessage();
?>

最佳答案

您可以检查 URL 中是否存在 GET 参数并相应地调用函数:

if(isset($_GET['writeMessage'])){
writeMessage();
}

关于php - 如何从地址栏调用 php 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24052683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com