Daily Learning Record of front-end Tom ---- php (1), Tom ---- php

Source: Internet
Author: User

Daily Learning Record of front-end Tom ---- php (1), Tom ---- php

What is PHP?

PHP:
The scripting language embedded in the html language that is executed by the web server;
. It can be written together with html;
. Php programs are executed by web servers;
. Php is a script language;

Web Server:
He is a software.
. Main functions:
Provide a service to ensure that the website can be accessed within 24 hours ....

Such as KFC and Internet cafe

If it is not opened, it means you cannot use server data.

Common web servers:
Apace, nginx, etc.

How to Use PHP?

1. Install the web server suite first.
The so-called kit is equivalent to a package for fast food restaurants in real life.
Common web server suite:
Phpstudy, xampp, appserver, wamp...
Learning Environment kit: phpstudy

URL: www.Phpstudy. Net/

Phpstudy mainly includes:

Php + apache + mysql;

He is a php running environment: script language + SERVER + Database System

2. Install phpstudy

Do not install your package in the Chinese path. After decompression, continue to the next step. After installation, run ---- click Run

------ When apache and mysql turn green, it indicates that the web server has started properly

 

Start writing php?
1. Create a. php file under the www directory of the phpstudy folder that has just been installed.
Do not name files in Chinese; otherwise, errors may occur.
2. In a. php, enter:

<? Php
// Php code
?>


Written in <? Php and?> The code between them is the php code,
Then, if it is written in <? Php and?> The code outside is generally considered as html code.
3. output text echo
Echo: displaying a piece of text in a browser is equivalent to js ---> document. write

<? Php

Echo 'hello ';

?>
4. How can I view the Code results? How to run
Note: Do not open it in a browser to run it.
Input in the browser:
Http: // localhost
Localhost is equivalent to the WWW directory
Http: // localhost/a. php
Click Enter to run the. php file under the www directory to view the effect.
5. Chinese garbled Solutions

Sometimes the Chinese output by echo is garbled. There are two solutions:
1. Add the header function to set the encoding (php method)
Header ("content-type: text/html; charset = UTF-8 ");
2. Add the meta header to set encoding (html method)
<Meta charset = "UTF-8"/>
6. the php statement uses the 'dot 'to connect strings.

Eg:

Echo "Beijing". "Welcome"; // Beijing Welcomes You

 

7. Data Type (var_dump ();)

Int // integer
String // string
Float // floating point number (decimal)
Bool // boolean type (true or false type)
Object // object
Array // array
NULL // NULL

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.