Home Backend Development PHP Problem What are the three naming methods in php

What are the three naming methods in php

Feb 10, 2022 pm 03:26 PM
php

The three naming methods of php are: 1. Little camel case naming method, the first word starts with a lowercase letter, the first letter of the second word is capitalized or the first letter of each word is capitalized ; 2. Pascal nomenclature (also called camel case nomenclature); 3. Hungarian nomenclature, the naming rule is "variable name = attribute type object description".

What are the three naming methods in php

The operating environment of this tutorial: Windows7 system, PHP7.1 version, DELL G3 computer

Three kinds of php Naming method

1. Camel case naming method:

Camel case (camel method) variables are generally identified with camel case.

The first word starts with a lowercase letter;

The first letter of the second word is capitalized or the first letter of each word is capitalized;

For example: myFirstName, myLastName

2. Pascal nomenclature (Upper Camel case nomenclature):

Upper Camel case method Case) is also called: Pascal nomenclature: (pascal method) is often used in class names, function names, attributes, and namespaces.

Compared with the small camel case method, the large camel case method also capitalizes the first letter of the first word. For example: public class DataBaseUser

The following are the same function named using camel notation and underscore method respectively:

  • ##printEmployeePaychecks(); Camel style nomenclature - each logical breakpoint in the function name is marked with an uppercase letter

  • print_employee_paychecks(); underscore method---- Each logical breakpoint in the function name is marked with an underscore.

3. Hungarian nomenclature:

The basic principle is: variable name = attribute type object description.

The key to Hungarian nomenclature is: the name of the identifier starts with one or more lowercase letters as a prefix; the prefix is ​​followed by a word or a combination of words with the first letter in capital letters, which should indicate the purpose of the variable. .

The Hungarian nomenclature identifies the scope, type, etc. of the variable by adding the corresponding lowercase letter symbol as a prefix in front of the variable name. These symbols can be used multiple times at the same time. The order is m_ (member variables) first, then pointers, then simple data types, and then others.

For example: m_lpszStr, represents a long pointer member variable pointing to a string ending with 0 characters.

Prefixes of lowercase letters commonly used in Hungarian nomenclature:

Prefix type

a Array(Array)

b Boolean )

by Byte(Byte)

c Signed Character(Char)

cb Unsigned Character(Char Byte, not many people use it)

cr color reference value (ColorRef)

cx,cy coordinate difference (length ShortInt)

dw Double Word

fn function

h Handle(handle )

i Integer type

l Long Int type(Long Int)

lp Long Pointer

m_ Class member

n Short Int type (Short Int)

np Near Pointer

p Pointer

s String type

sz Null-terminated string type ( String with Zero End)

w Word

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of What are the three naming methods in php. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

See all articles