PHP Learning Memories

Source: Internet
Author: User
PHP Learning Memories


The flower two months study?? PHP? Fur, is to write a complete?? Out?
What will you learn in two months? Remember low, bother to forget later, do scare remember all good

----------------------------------------------------------------------------------------

PHP Learning Memories 1
Now let's get started ~ ~

Construction of the environment
Let's talk about Wamp (windows+apache+mysql+php)
Windows:win2k SERVER SP4
apache:2.0.59
Php:5.2.1-dev
mysql:5.0

Installing Apache
First download the MIS installation package for Windows from http://httpd.apache.org/, open IE after installation, enter http://localhost, if display it Works, indicates the installation is successful.

Install PHP
To http://www.php.net download Windows Zip package, unzip to a directory, for example: c:\php, go to extract directory, find php.ini-recommended, renamed to PHP.ini, open php.ini, find DOC_ Root =, change the path to the Web path you want to set, for example doc_root = "C:\web", find Extension_dir =, change to Extension_dir = "C:\php\ext".

The following settings load the appropriate module for PHP
Find the following content
Extension=php_mbstring.dll
Extension=php_gd2.dll
Extension=php_imap.dll
Extension=php_msql.dll
Extension=php_mysql.dll
Extension=php_xmlrpc.dll
Extension=php_xsl.dll
Extension=php_mysqli.dll
Remove the semicolon from the front.

The following settings for PHP settings session and Cookies
Find Session.save_path =, change the session path you want to set, for example Session.save_path = "C:/temp", if the system does not need to set the session, here can not set.
Find session.use_cookies =, change to Session.use_cookies = 1, again, if you do not need to use cookies, you can not set them here.
Find Session.name =, change to Session.name = Phpsessid.
Find Session.auto_start =, change to Session.auto_start = 0.

The following settings mbstring the default language
Find Mbstring.language =, change to Mbstring.language = Chinese Simplified.
Save and exit.

Locate the Php5ts.dll, Libmysql.dll,copy, and C:\Winnt directories under the c:\php directory

Set Apache
into the Conf directory under the Apache installation directory, find httpd.conf, open with Notepad, find listen, this is the Web service listening port, the default is 80, you can modify the other ports you want to set.
Find dynamic Shared Object (DSO) support, join the dynamically sharing file
and add the LoadModule php5_module "C:/php/php5apache2.dll" on the last side, if it is PHP4, The LoadModule php4_module "C:/php/php4apache2.dll" is changed.
Locate ServerName, change the computer name of the server, for example: ServerName hostname:80, if it is already in the domain, it is best to enter the FQDN.
Locate DocumentRoot and change to the default path for the Web, for example: DocumentRoot "C:/web".
Similarly, locate , instead Locate AddType application/x-gzip. gz. tgz, add the following below
Script alias/php/"c:/php"
AddType application/x-httpd-php. php. PHP5
Action application/x-httpd-php "/php/php-c Gi.exe "
Phpinidir" c:/php "
to save and exit.


To complete the Apache and PHP settings here, restart the Apache service, if it starts normally, create a new Notepad in the C:\web directory, and enter the following:

Save As phpinfo.php, open http://localhost/phpinfo.php, if normal, will display the server's PHP settings environment, then the settings are successful, and can find the information that has been loaded, such as GD2, mSQL, XMLRPC, XSL, etc.
If the Apache service fails to start, or if you open http://localhost/phpinfo.php to display only the contents of the file, then there is a problem with the setup and you can check the Apache log file for troubleshooting.


Good resistance has not been updated, continue

Catch the Fall? Go to http://www.mysql.com download MySQL
All the way installed, installed? The Administrator password will be required
After installation, log in in cmd, Mysql-u root-p
Then enter the root password and enter the following to
SET PASSWORD for
' Some_user ' @ ' some_host ' = Old_password (' newpwd ');
Then you can log in to MySQL normally.

If you forget the root password for MySQL, you can reset it in the following ways:

1. Kill the MySQL process in the system;

2. Start MySQL with the following command to start without checking permissions;

Mysqld_safe-skip-grant-tables &

3. Then log in to MySQL using the root user with a blank password;

Mysql-u Root

4. Change the password of the root user;

mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';mysql> flush privileges;mysql> quit

5. Restart MySQL to log in with the new password.

MySQL Manual chapter II has introduced

-----------------------------------------------------------------------------------

PHP Learning Memories 2
Define variables:
$i; Define a $i variable, which can be any type
$i = 123; Define a $i variable, type int, and of course float ...
$i = "123";
$i = ' 123 '; Ibid., define a $i variable, string type

What's the difference between ' and '? Forget, if the string is only strings, does not contain other words, "better, if there are other things, it is better to use", such as include variables, constant null, etc...
A simple example:
$i = "Today is {$today}";
The example above is to define a $i variable with the content "Today is {$today}", $today is another variable, the content is today's date, for example "January 29, 2007"
When the output variable $i, the content is "today is January 29, 2007"
So, what is the role of {}? When a string contains a variable, you can use {} to include the variable name, the output string, when PHP encounters $xxx, the program will look for the variable $xxx, find the value of the variable $xxx, then the corresponding value output, and then continue to output the original string

The output inside PHP
Echo
echo can output variable values, strings, numbers
For example:
echo $i; The value of the output variable $i
echo "123";
echo ' 123 '; Same as output string 123, without "" or "
Echo 123; Output number 123
Because PHP is an HTML embedded language, ECHO can also output HTML code
For example:
echo "

";
The above code outputs a row-by-column table
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.