Home>Article>Backend Development> What does dollar sign mean in php

What does dollar sign mean in php

(*-*)浩
(*-*)浩 Original
2019-09-06 14:44:06 5147browse

What does dollar sign mean in php

The $ symbol in php is a variable symbol;

Add the $ symbol to a string, and this string is A variable name or object name.

In fact, PHP uses the syntax of C language, but there are some differences. The $ sign plus a string is a variable name or object name.

For example, the following code: (Recommended learning:PHP programming from entry to proficiency)

class MyClass{ private $_val; public function foo(){ return $this->_val; } public function foo1(){ return $this->_val; } ...... } $my = new MyClass; echo $my->foo();

MyClass is a class name, no $ sign is needed; $_val is a private variable , usually composed of $ followed by an underscore and a string; foo and foo1 are two member functions, so there is no need to add the $ sign; $my is an object and must be added with the $ sign.

The above is the detailed content of What does dollar sign mean in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:what is php middleware Next article:what is php middleware