您的位置 首页 php

零基础学习PHP篇变量声明赋值超全局变量获取记录等

变量

1.变量声明

变量以美元符 $ 开头,然后是变量名;

变量名由字母或下划线开头,由字母,下划线,数字组成;

变量名区分大小写;

php 是弱类型的语言,不需要事先声明变量的数据类型;

php可以不用显示的声明变量就直接使用,不过好的编码习惯:所有的变量在使用前应该进行声明;

例: $age = 25;

$color = ‘red’;

$sum = 12 + “15”; // $sum = 27 (“//” 为注释的意思)

2.变量赋值

(1). 值赋值:就是将赋值表达式的值复制到变量;

(2). 引用赋值:php4引入了引用赋值功能,创建的变量与另一个变量引用的内容相同。

例:

$val_1 = ‘hello’;

$val_2 = &$val_1; //把$val_1的内存空间地址赋值给$val_2,是同一个变量

$val_2 = ‘goodbye’;

$var_1 = ‘goodbye’;

3.变量的变量

$val_1 = ‘hello’;

$$val_1 = ‘world’;

echo $hello;

echo $val_1;

echo ${$val_1};

2.PHP的超 全局变量

php提供了很多有用的预定义变量,用于提供大量与环境有关的信息。

(1). $_SERVER 服务器变量

该全局变量包含着服务器和客户端配置及当前请求环境的有关信息

$_SERVER[‘SERVER_NAME’]; : 当前运行脚本所在的服务器的主机名

$_SERVER[‘REMOTE_ADDR’]: 客户端IP地址

$_SERVER[‘REQUEST_URI’]: URL的路径部份

$_SERVER[‘HTTP_USER_AGENT’] : 操作系统和浏览器的有关信息

(2). $_GET

该变量包含使用 GET 方法传递的参数的有关信息;

例:

url:

$id = $_GET[‘id’];

$page = $_GET[‘page’];

(3). $_POST

该变量包含使用 POST 方法传递的参数的有关信息;

例:html:

<form name=”reg” action=”test.php” method=”post”>

用户名:<input type=”text” name=”username” />

密码: <input type=”password” name=”passwd”/>

<input type=”submit” value=”提交” />

</form>

php部分:

$username = $_POST[‘username’];

$passwd = $_POST[‘passwd’];

(4). $_REQUEST

该变量记录着通过各种输入方法传递给脚本的变量,如GET POST,但不要用这个超级全局变量,因为它不安全而且速度比较慢;

(5). $_COOKIE cookie变量数组

(6). $_SESSION 会话变量数组

(7). $_FILES 与上传文件有关的变量数组

(8). $_ENV 环境变量 数组

(9). $GLOBALS 所有全局变量数组

下一节将讲到常量、数据类型等。

文章来源:智云一二三科技

文章标题:零基础学习PHP篇变量声明赋值超全局变量获取记录等

文章地址:https://www.zhihuclub.com/79843.shtml

关于作者: 智云科技

热门文章

评论已关闭

37条评论

  1. Thus, make sure that you inform your health practitioner about your medical history and provide him with a complete list of medicines that you are taking at present

  2. On howviagraworks tightening budget controls on farm shipments was about 30 seconds to 2007

  3. The aim of the present study was to attempt to fill this gap in order to clarify the proper approach to COH in smokers and to aid fertility specialists and their patients in the decision-making process.

  4. pneumococci after passing through a few subcultures on agar, but they will again produce capsules and have enhanced virulence Virulence The degree of pathogenicity within a group or species of microorganisms or viruses as indicated by case fatality rates and or the ability of the organism to invade the tissues of the host. Had my worst prostatitis when I was 39.

  5. Proviron is the brand name for the steroid hormone powder mesterolone, a testosterone derivative similar in structure to the naturally occurring hormone Dihydrotestosterone DHT

  6. Hang in there and make the best of your good days Since primary cilia are important in development, extensive studies have been done recently to uncover their structure and associated proteins 10, 11

  7. In another embodiment, the triglyceride itself can have therapeutic value as, for example, a nutritional oil, or absorption promoting value as, for example, a long chain triglyceride LCT, having fatty acid chains longer than C10 and preferably C12 C22 or a medium chain triglyceride MCT, having C6 C10 fatty acid chains We, therefore, analyzed the expression of maspin SERPINB5 and survivin BIRC5 in tumors from different dietary treatments

  8. Next generation sequencing technique is gradually replacing capillary electrophoresis as the preferred modality for clonality detection given its higher sensitivity 15 Sebaceous neoplasms 16 Immunohistochemistry for mismatch repair proteins PMS2, MSH6, MLH1, MSH2 can be performed on biopsies FFPE demonstrating sebaceous adenomas, sebaceomas, and sebaceous carcinomas to screen for Muir Torre Syndrome

  9. In addition to a significant improvement in PFS, trametinib therapy also resulted in a higher response rate than SOC Dx 6 30 2017, IDC, Left, 6cm, Stage IV, metastasized to bone, Grade 2, ER PR, HER2 Hormonal Therapy 8 4 2017 Femara letrozole, Zoladex goserelin Targeted Therapy 9 1 2017 Kisqali Targeted Therapy 3 9 2018 Ibrance palbociclib

  10. levodopa flovent hfa gsk coupon The emergence of Mr Sayyaf, Ismail Khan and Gen Dostum in the presidential election will be highly unwelcome among international donor nations who have expended huge amounts of money and lost lives to stabilise Afghanistan citrate tab

  11. xalatan benzac10 Not all business travel gets reimbursed, nor do all mealswith clients or gifts for clients such as the wine and throwpillows real estate agents give their customers

  12. This condition, reportedly caused by mixing furosemide and Weed, describes a marijuana induced condition where the user experiences episodes of violent vomiting, which are often so severe and painful that they cause the person to scream

  13. We found Ccne and Ccnd2 were consistently and significantly downregulated following WNT pathway inhibition MRI indicates magnetic resonance imaging

  14. Seeing that Oran didn t care about his own existence at all, and carried out a ceremony within the elf family, it may be regarded as a rare and terrifying ceremony Total RNA was extracted with innuPREP Micro RNA Kit Analytik Jena, Austria and RNA quality was verified on an Agilent 2100 bioanalyzer

  15. They should be prescribed cautiously to patients in whom the presence of edema would be detrimental

  16. So it s safe to say that the lack of symptoms thereof doesn t always mean bad Looking at Rumsfeld, Physician s anger couldn t help but rise again, His real heartache is not that Feng Die s heart belongs, but the death of more than 400 Dark Side of the Moon warriors

  17. This subtype includes ERО± and PR tumors, in which 66 of patients fail to respond or develop early resistance to the selective ER modulator, tamoxifen 15, 16

  18. TRAP induced platelet release of VEGF per 10 6 platelets was similar at baseline in women treated with tamoxifen 0

  19. Rabbit anti RFP 632496; Clontech, Mountain View, CA, and chicken anti GFP ab13970; Abcam, Cambridge, MA were also used

  20. Tamoxifen, radiation therapy, or both for prevention of ipsilateral breast tumor recurrence after lumpectomy in women with invasive breast cancers of one centimeter or less

  21. Epidemiological studies have suggested that elevated plasma cholesterol levels are associated with an increased risk of mortality and increased risk of breast cancer after menopause The breast procedures that reduce breast cancer risk include total mastectomy, skin sparing mastectomy, and subcutaneous mastectomy

网站地图