解决$_REQUEST['name']Undefined问题
最近按照w3school一步一步学php,当学到$_REQUEST的时候,依旧按照w3cshool所提供的代码自己手敲了一遍,代码如下:
<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name:<input type="text" name="fname"/>
<input type="submit" >
</form> <?php
$name = $_REQUEST['fname'];
echo $name;
?>
</body>
</html>
当运行的时候会提示如下错误:

很明显我们需要判断一下$_REQUEST['fname']的值是否为空,需要使用php的isset()函数
格式:bool isset ( mixed var [, mixed var [, ...]] )
功能:检测变量是否设置
返回值:
若变量不存在则返回 FALSE
若变量存在且其值为NULL,也返回 FALSE
若变量存在且值不为NULL,则返回 TURE
同时检查多个变量时,每个单项都符合上一条要求时才返回 TRUE,否则结果为 FALSE
因此把代码改成如下:
<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name:<input type="text" name="fname"/>
<input type="submit" >
</form>
<?php
if(isset($_REQUEST['fname']))
{
$name = $_REQUEST['fname'];
echo $name;
}
?>
</body>
</html>
效果如下:

解决$_REQUEST['name']Undefined问题的更多相关文章
- 安卓Notification的setLatestEventInfo is undefined出错不存在的解决
用最新版的SDK,在做状态栏通知时,使用了Notification的setLatestEventInfo(),结果提示: The method setLatestEventInfo(Context, ...
- 关于undefined reference to `WSASocketA@24'问题的解决
关于 Eclipse 开发C++ Socket ,在开发的过程中 用WinGW 平台编译, 示例server端: #include <winsock2.h> #include <m ...
- Call to undefined function mssql_connect()错误解决
原文:Call to undefined function mssql_connect()错误解决 同事用php+mssql修改一个系统,却一直配置不了环境.遂做了一个测试,一般情况下我们会注意php ...
- 【错误】undefined reference to `boost::....的解决
很多新手引用Boost库编程,在ubuntu下编译时候有时候会出现如下错误: test04.cpp:(.text+0x2c): undefined reference to `boost::progr ...
- libsvn_subr-1.so.0: undefined symbol: apr_atomic_xchgptr 故障解决
源码编译安装完成之后,查看svn的安装版本会报以下错误 svn: symbol lookup error: /usr/local/subversion/lib/libsvn_subr-.so.: un ...
- DJANGO_SETTINGS_MODULE is undefined报错的解决
问题: ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is ...
- “Uncaught TypeError: Cannot call method 'createChild' of undefined" 问题的解决
Uncaught TypeError: Cannot call method 'createChild' of undefined 我在使用Ext 4.1.1做grid.Panel,然后chrome爆 ...
- apache安装mod_ssl.so 出现 undefined symbol: ssl_cmd_SSLPassPhraseDialog错误解决
很久很久以前,安装Apache的时候,根本没想过将来的某一天会使用到ssl,所以也就没有安装那个模块,结果今天需要用到的时候,却无从下手了. 由于在安装Apache的时候,mod_ssl.so这个文件 ...
- CMake undefined reference to `QTcpServer::QTcpServer(QObject*)'的解决
1. 这是因为工程link不到network的库,因此除了要包含头文件 #include 之外,还需要在.pro文件中加入: QT += network 2. 对于CMake,需添加Net ...
随机推荐
- Educational Codeforces Round 7 C. Not Equal on a Segment 并查集
C. Not Equal on a Segment 题目连接: http://www.codeforces.com/contest/622/problem/C Description You are ...
- discuz+ecmall+phpcms整合
所需软件 discuzx1.5 (包含ucenter1.5) ecmall2.3 phpcms v9.5 1.先安装discuz1.5 2.然后安装ecmall2.3 3.最后安装phpcms v9. ...
- [AngularJS] Adding custom methods to angular.module
There are situations where you might want to add additional methods toangular.module. This is easy t ...
- jQuery css() 方法
$("p").css("background-color"); $("p").css("background-color" ...
- sqlserver2008 复制,镜像,日志传输及故障转移集群区别
一, 数据库复制 SQL Server 2008数据库复制是通过发布/订阅的机制进行多台服务器之间的数据同步,我们把它用于数据库的同步备份.这里的同步备份指的是备份服务器与主服务器进行 实时数据同步, ...
- 云服务器 ECS Linux 系统 CPU 占用率较高问题排查思路
https://help.aliyun.com/knowledge_detail/41225.html?spm=5176.7841174.2.2.ifP9Sc 注意:本文相关配置及说明已在 CentO ...
- Linux内存管理学习笔记 转
https://yq.aliyun.com/articles/11192?spm=0.0.0.0.hq1MsD 随着要维护的服务器增多,遇到的各种稀奇古怪的问题也会增多,要想彻底解决这些“小”问题往往 ...
- Linux中断(interrupt)子系统之一:中断系统基本原理 (图解)
http://blog.csdn.net/droidphone/article/details/7445825
- android studio 预览保持,因为是SDK版本过高,可以点击小图标机器人修改SDK版本号。
Exception raised during rendering: com/android/util/PropertiesMap
- Golang学习 - 学习资源列表
Golang 学习资源: <Go 语言圣经(中文版)> - 书籍 http://shinley.com/index.html <学习 Go 语言> - 书籍 http://w ...