Home  >  Article  >  Backend Development  >  What does $ in php mean?

What does $ in php mean?

烟雨青岚
烟雨青岚Original
2020-06-13 09:12:446563browse

What does $ in php mean?

PHP is an HTML embedded scripting language. php files end with .php. Much of its syntax comes from C, Java, and Perl, and it has several features unique to PHP. The main goal of the language is to allow web developers to quickly write dynamically generated web pages.

The $ symbol in PHP means: variable

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

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 need to add $ sign. $_val is a private variable, usually composed of $ followed by an underscore and a string. foo and foo1 are two member functions. There is no need to add the $ sign, $my is an object, and the $ sign must be added.

Recommended tutorial: "php tutorial"

The above is the detailed content of What does $ in php mean?. 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