PHP是一种用于创建动态WEB页面的服务端脚本语言。如同ASP和ColdFusion,用户可以混合使用PHP和HTML编写WEB页面,当访问者浏览到该页面时,服务端会首先对页面中的PHP命令进行处理,然后把处理后的结果连同HTML内容一起传送到访问端的浏览器。但是与ASP或ColdFusion不同,PHP是一种源代码开放程序,拥有很好的跨平台兼容性。用户可以在Windows NT系统以及许多版本的Unix系统上运行PHP,而且可以将PHP作为Apache服务器的内置模块或CGI程序运行。
除了能够精确的控制WEB页面的显示内容之外,用户还可以通过使用PHP发送HTTP报头。用户可以通过PHP设置cookies,管理用户身份识别,并对用户浏览页面进行重定向。PHP具有非常强大的数据库支持功能,能够访问几乎目前所有较为流行的数据库系统。此外,PHP可以与多个外接库集成,为用户提供更多的实用功能,如生成PDF文件等。
用户可以直接在WEB页面中输入PHP命令代码,因而不需要任何特殊的开发环境。在WEB页面中,所有PHP代码都被放置在“<?php”和“ ?>”中。此外,用户还可以选择使用诸如<scrīpt LANGUAGE="php"></scrīpt>等的形式。PHP引擎会自动识别并处理页面中所有位于PHP定界符之间的代码。
PHP脚本语言的语法结构与C语言和Perl语言的语法风格非常相似。用户在使用变量前不需要对变量进行声明。使用PHP创建数组的过程也非常简单。PHP还具有基本的面向对象组件功能,可以极大的方便用户有效组织和封装自己编写的代码。
PHP语法概述
A. 基本语法
即使初次接触PHP的用户也会发现自己对PHP的语法风格并不陌生。
例如:<?php
echo “Hello!”;
?>
显示结果为“Hello!”。
PHP中,所有的变量都以标识“$”开头。我们可以对上述代码做如下改动:
<?php
$greeting = “Hello!”;
echo $greeting;
?>
改变后的代码显示结果不变。
PHP中使用“.”符号连接不同的字符串,而其它的算术运算符则继承了流行编程语言的风格。举例如下:
<?php
$greeting = “Hello!”;
$num = 3 + 2;
$num++;
echo “$greeting $num people!”;
?>
显示结果为“Hello!6 people!”。
PHP对各种运算符及运算规则都有一套完整的规定,如果用户具有C或C++语言的编程背景的话,可以发现一切都得心应手。
与Perl语言一样,在PHP中,如果在双引号包含的字符串中含有变量的话,该变量将用相应的变量值替换;如果字符串被单引号包含,则不做替换。例如:
<?php
$name = ‘PETER’;
$greeting_1 = “Hello, $name!”;
$greeting_2 = ‘Hello, $name!’;
echo “$greeting_1n”;
echo “$greeting_2n”;
?>
显示结果为:
Hello, PETER!
Hello, $name!
(注:上述代码中的“n”为换行符,只能在双引号字符串下使用)
Last year, the New York Times published the results of its census analysis stating that 51% of U.S. women live without a spouse. However, Sperling's BestPlaces discovered this might not be the whole story.
"The Times came to some insightful conclusions with their analysis," said Bert Sperling, lead researcher for Sperling's BestPlaces. "We made some different assumptions to more closely reflect our national lifestyle where fifteen year-old girls aren't commonly expected to get married."
The New York Times used, at that time, the latest demographics from the Census Bureau, including women above age fourteen who were unmarried or separated. Indeed, according to cheap wow gold a University of Texas survey, the average age of women at their first marriage is 26.
Sperling's firm looked at similar Census data, but restricted its analysis to single, widowed, and divorced women age 25-64. Without this cap on the age range, places with higher concentrations of elderly people would show a misleading number of single women.
Sperling's conclusion is significantly different than the New York Times. In the 379 metro areas nationwide, 34% of women 25-64 are single.
Despite all the attention to this new milestone for wow gold single women, the difference between the number of single men and women is not as great as one might think. Nationally, 32% of men are single.