The definition of variables in PHP learning note-php

Source: Internet
Author: User

PHP variables are not type , which is completely different from C language, C language inside we define a variable must be added variable type, such as int a=10; Char b[10]={0}; in PHP we define a variable like this

$length = 100;

To see its characteristics, it is to define a variable with a "dollar sign at the beginning plus variable name" .

There are some advantages and disadvantages of variable types and languages that do not have variable types.

C language is a variable type, because C language born earlier, that time memory is more tense, wasting memory is lethal ah, so memory area is divided into triangular area, square area, circular area, if the triangle must be placed in the Triangle area inside, other areas are not put in, The rest is the same. The advantages are obvious, make full use of memory, save resources, the shortcomings are obviously not flexible, the memory management of this technology content is higher than the work of programmers to complete, the programmer requirements are relatively high.

PHP is not a variable type, because with the progress of science and technology, memory space is relatively less tense, in order to write programs more efficiently, in order to liberate productivity, PHP was designed to be no variable type. The area of memory is divided into large jars, whether you are a triangle or a circle or a square, which you can put in. The advantages are obvious, very flexible, the programmer does not need to focus on memory management, the shortcomings are not yet known, it may be more waste of memory.

Points to note:

Variables in 1.PHP are case-sensitive.

2. This is a mistake I often make when defining a variable with a dollar sign and forgetting to write a dollar sign when referencing a variable.

<?php

$books = ' Chinese ';

Echo Books;

OUTPUT Books

?>

<?php

$books = ' Chinese ';

Echo $books;

OUTPUT Chinese

?>

The definition of variables in PHP learning note-php

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.