duanpuqi9965 2011-01-04 21:44
浏览 14
已采纳

PHP,包含参数

I have a PHP-file which will be called from a form. So it gets parameters over $_GET.

Now I need the exact same functionality of this file, but not in such a form-call. I will include it in normal code with fixed parameters (which normally come from the form). So my file can work with the form AND without it.

I know only the way with include and setting the $_GET in front of it. But I am not sure this is the most elegant way (I dont like the idea of setting things like $_GET).

any other ways of doing this?

br, chris

  • 写回答

5条回答 默认 最新

  • dongxi3859 2011-01-04 21:48
    关注

    You can convert the code to a function that takes an associative array as its parameter.

    That way, you can just include it when necessary and call the function with either $_GET or an array you build yourself.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 关于无人驾驶的航向角
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了