30 minutes to learn the PHP language immediately

Source: Internet
Author: User
Tags learn php
30 minutes to learn the PHP language immediately

It's no exaggeration to say so, but you have to have a little programming base. I am talking about learning PHP language is not learning to use PHP to build Web applications AH. This language is not difficult, very simple because PHP is web-oriented, syntax is easy to understand, but to build the site also involves web editor, server and so on, but don't be sad to read this you know how to learn PHP, how to make a good website. Rome cold day, to do the site still have to work harder, but also really not difficult.

1.Php markup is best used in this way to shorten the system compilation time. Of course <%??? %> or there is also a possible.

2. notes

/ * Multiple lines of

Comments */???

// single-line comments

# Single-line comments

3. instruction delimiter each instruction must end with ";".

4. The variable begins with $ :$ab = ' Zhaohua ';

Like a normal high-level language. Its variables are also case-sensitive and cannot begin with a number. No declaration is required before use, which is not the same as other high-level languages. is a weakly typed language. But don't underestimate PHP ! Because PHP is a web language requirement is fast so, unlike other languages, there is no need to declare beforehand.

5. Constants: There are many systems with built-in constants:Php_os to display the operating system information,php_version display PHP version ... Check the PHP Manual for specifics.

You can also customize define("name", "php"), and// give php this exposition to NAME.

6. data type:

Four scalar types:integer,boollean,float,string.

Mixed types:Array (array) and object (objects)PHP is Object-oriented.

PHP Specific special type:resource? (Connecting the database sometimes returns data is resource),

null(empty type) type such as:$b =null;

Note:var_dump () can be used to view the type of a variable, if your code is long you forget, or when you look at someone else's code ...

7. A lot of common functions can not be fully understood, but the most basic still need to remember AH.

Like what:

strlen ()? Check the length of the string

strcmp () strcasecmp () strncmp ()

strstr () string substitution ? Stristr ()

trim ()? Go to the Space LTrim () go to the right RTrim () to the left

printf ()? Output different types of values

Ksort () Sort by array index ? Sort () sorted by array element

8.php does not support methods, operator overloading, or inheritance. Because he is, after all, an object-oriented Web language. There was a request for support, and there was opposition, and there was no support for it. let others comment.

9. function ? All of the functions are defined by function, which, like JavaScript scripts, are all WEB -oriented, so it's easy. For example:

function Display_size ($file) {// How to determine the file size, is G ah or M ah?

$file _size=filesize ($file);

If ($file _size>=100202)

{

??????? $file _size=round ($fiel _size/100202*100)/100. " G ";

}

Elseif ($file _size>=45202)

{

????? $file _size=round ($fiel _size/45202*100)/100. " M ";

}

Return file_size;

}

The echo function is the same as print and is used to display.

echo $abc;// used to display the value of $abc .

One . If you want to use more functions or functional frameworks, then download PEAR(PHP Extensions and applications), a reusable PHP -built framework and distribution system that contains 442 Packages and more than one theme, the API in thedb package is used to connect to the database Ah,Mail package Ah,Net_socket ..., of course, if you don't like it, you can make it yourself.

template (template)

j2ee know we have struts2 , php of course there are many templates, But for the new people to start with the basic knowledge of the most important, these templates can be used to work later, and now we do not use these templates can still make a good site or web application, also quickly. These templates just require stricter possible bug will be less, and there are a lot of integration features of our own development, but no foundation of people difficult to get started, because your base for 0 Ah, But if you want to learn the words are not difficult, the next template down, let's look at its detailed explanation, and then a little look at the code (do not need to fully understand only a familiar can be applied, if you want to learn this knowledge, carefully study it is not a bad thing, if just want to apply, I feel a little waste of time, With people). For example: smarty , savant , tinybutstrong,template Lite ... ... Can be down from the Internet, some companies have their own templates, you can also make a template, if you feel you are very good soon, no bug very convenient words. What do you do in the future site what php Application system can be used.

We learn from this point is not a good thing, we may encounter a lot of problems then how to do? We can check the PHP Manual, Baidu, or go to some technical blog to see, for example:

?

Http://hi.baidu.com/bazhaohua/blog? E -Net love deep ??? http://www.phpchina.com ? PHP China

  • 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.