PHP(3)Update the Version and Read the Doc Grammar
1. Check MAC Software Installation
Check the version of apache
>sudo apachectl -v
Server version: Apache/2.2.26 (Unix) Server built: Dec 10 2013 22:09:38
Start the Server
>sudo apachectl start
Uncomments this line is /etc/apache2/httpd.conf
LoadModule php5_module libexec/apache2/libphp5.so
Prepare the configuration
>sudo cp php.ini.default php.ini
Prepare the php file
>cat /Library/WebServer/Documents/info.php
<?php phpinfo(); ?>
Visit the page http://localhost/info.php
PHP Version 5.4.24
I already have my mysql.
I download the file http://us1.php.net/distributions/php-5.5.12.tar.gz
2. PHP Grammer
Link the working directory under apache document root
>sudo ln -s /Users/carl/work/easy/easyphp /Library/WebServer/Documents/easyphp
Array
$arr = array("foo" => 1, 12 => true);
echo gettype($arr[12]) . "<br />";
echo $arr[12];
output:
boolean
1
If we did not set the key, it will be the max key + 1.
unset($arr[5]); // This removes the element from the array
unset($arr); // This deletes the whole array
// Create a simple array.
$array = array(1, 2, 3, 4, 5);
print_r($array);
echo "<br />";
// Now delete every item, but leave the array itself intact:
foreach ($array as $i => $v) {
unset($array[$i]);
echo "unset $i => $v" . "<br />";
}
The array_values() function can be used to 'remove and shift’.
$arr = array('fruit' => 'apple', 'veggie' => 'carrot');
// Correct
print $arr['fruit']."<br />"; // apple
print $arr['veggie']."<br />"; // carrot
// This defines a constant to demonstrate what's going on. The value 'veggie'
// is assigned to a constant named fruit.
define('fruit', 'veggie');
// Notice the difference now
print $arr['fruit']."<br />"; // apple
print $arr[fruit]."<br />"; // carrot
<?php
$a_bool = TRUE; // a boolean
$a_str = "foo"; // a string
$a_str2 = 'foo'; // a string
$an_int = 12; // an integer
echo gettype($a_bool); // prints out: boolean
echo '<br />';
echo gettype($a_str); // prints out: string
// If this is an integer, increment it by four
if (is_int($an_int)) {
$an_int += 4;
}
echo "<br />";
echo $an_int;
// If $bool is a string, print it out
// (does not print out anything)
if (is_string($a_bool)) {
echo "String: $a_bool";
}
?>
class foo
{
var $foo;
var $bar;
function foo()
{
$this->foo = 'Foo';
$this->bar = array('Bar1', 'Bar2', 'Bar3');
}
}
$foo = new foo();
$name = 'MyName';
echo <<<EOT
My name is "$name". I am printing some $foo->foo.
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': \x41
EOT;
?>
The above example will output:
My name is "MyName". I am printing some Foo.
Now, I am printing some Bar2.
This should print a capital 'A': A
References:
PHP(1) ~ (2)
http://sillycat.iteye.com/blog/1543227 win7 php installation and php types
http://sillycat.iteye.com/blog/1638638 MAC php installation
http://sillycat.iteye.com/blog/1040371 PHP installation on ubuntu
PHP(一) ~ (三)
http://sillycat.iteye.com/blog/768664 installation
http://sillycat.iteye.com/blog/769110 hello world
http://sillycat.iteye.com/blog/770369 basic grammer
http://sillycat.iteye.com/blog/731677 ogame source codes setup
http://www.php.net/
http://www.php.net/manual/en/language.types.array.php
- 浏览: 2560703 次
- 性别:
- 来自: 成都
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
相关推荐
### 图形语法(The Grammar of Graphics):统计可视化的核心理论 #### 一、引言 《图形语法》(The Grammar of Graphics) 是一本在统计学和数据可视化领域具有里程碑意义的著作,它由 Leland Wilkinson 编写,并于...
【标题】: "A unit 2 Vocabulary and grammar练习题精选.doc" 【描述】: 这份文档包含了8A第二单元的词汇与语法精选练习题目,旨在帮助学生巩固和提升英语学习中的词汇和语法知识。 【标签】: "文档" 【部分内容...
### 图形学经典教材《The Grammar of Graphics》第二版概览与知识点解析 #### 一、书籍背景介绍 《The Grammar of Graphics》是一本在图形学领域享有盛誉的经典教材,由Leland Wilkinson撰写,第二版出版于2005年...
3. **未来被动语态的用法**: - **按计划或安排将要发生的动作**:当我们将要进行的动作是根据已知的计划或安排来确定的,通常使用未来被动语态。例如:"The next Olympic Games will be held in Paris in 2024."...
能够对word里的汉语和英文进行语法检测,并能够提出修改意见,对于写论文有很大的帮助,快速比较简单。
To make grasping grammar easier--and more fun--Just Enough English Grammar uses colorful cartoons illustrate each important grammar point. You see the grammar concept in action, guaranteeing you will ...
这篇文档标题为"English around the world - Grammar 学案",说明这是一个关于全球英语语法的学习材料。从内容来看,主要涉及的是将直接引语转化为间接引语的语法知识点。 直接引语是直接引用某人说的话,而间接...
【Unit 4 Grammar I and II】是丽华中学张咏梅老师提供的一个英语语法练习题集,主要关注的是If引导的条件句以及动词的时态应用。在If引导的条件句中,通常分为两种类型:真实条件句(第一种情况)和非真实条件句...
《Better Grammar in 30 Minutes a Day》是由Constance Immel和Florence Sacks两位专家精心编著的英语语法提升指南书,该书由Career Press出版于1994年。本书的出现,对于那些希望提高英语写作准确性和流畅性的人们...
3.The database auto-update. Carry out the database auto-update without affecting the data of the original table. In addition, you can carry out the database auto-update development quickly and ...
3.The database auto-update. Carry out the database auto-update without affecting the data of the original table. In addition, you can carry out the database auto-update development quickly and ...
3.The database auto-update. Carry out the database auto-update without affecting the data of the original table. In addition, you can carry out the database auto-update development quickly and ...
在七年级英语下册Unit4 My Classroom的Grammar and Task部分,主要学习了与教室环境相关的词汇和表达,以及如何使用There be句型来描述物体的存在位置。以下是对这部分内容的详细解析: 1. **学习短语**: - 一块...
【人教版高中英语必修二Unit 3 Computers Period 5 Grammar】教学方案主要围绕现在完成时的被动语态展开,旨在帮助学生理解和正确运用这一语法结构。现在完成时的被动语态在英语中有着重要的应用,特别是在描述过去...
- 时间状语:now -> then, today -> that day, yesterday -> the day before, tomorrow -> the next day, tonight -> that night - 地点状语:here -> there - 动词:come -> go, bring -> take 3. **人称代词的...
2. 原句:“Don’t pass until the green light is on,” the policeman said to him. 转换为:The policeman told him not to pass until the green light was on. 这些转换遵循了人称、时态和语序的变化规则。 ...
Low Level I/O - Read and Write Open, Creat, Close, Unlink Random Access - Lseek Example - An implementation of Fopen and Getc Example - Listing Directories Example - A Storage Allocator Appendix...