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
- 浏览: 2495926 次
- 性别:
- 来自: 成都
最新评论
-
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
相关推荐
A unit 2 Vocabulary and grammar练习题精选.doc
The Grammar of Graphics可视化图形语法 书籍下载
This book and audio compact disc program instructs students of English as a second language in the elements of grammar, presenting a grammar review that emphasizes speech and correct pronunciation....
人教版高中英语必修二教案:unit 2 the olympic games period 5 grammar.doc
English around the world-Grammar学案.doc
Friendship-Grammar and language points学案.doc
Case,Typology,and Grammar
The grammar is embodied in a simple And–Or graph representation where each Or-node points to alternative sub-configurations and an And-node is decomposed into a number of components. This ...
能够对word里的汉语和英文进行语法检测,并能够提出修改意见,对于写论文有很大的帮助,快速比较简单。
Better Grammar in 30 Minutes a Day.doc
a Unit 4 Grammar I and II练习题精选.doc
English around the world-Grammar学案(1).doc
2016-2017学年 人教版 必修2 Unit2 the Olympic Games period2 grammar 教案.doc
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 ...
The Only Grammar Book You'll Ever Need A One-Sto 英语语法
图形学方面的经典教材,英文版第二版,希望对大家有帮助
in turn, become enshrined in grammar books directed at teachers and students The misrepresentation of English grammar gives a false view of the language, perpetuates inaccurate 'rules', and results ...
高中英语:Unit 2 English around the world Grammar(新人教必修1).doc
英语优秀教学案(人教版):必修一 Unit 3 Travel journal Period 3 Grammar.doc