这个代码竟然能跑起来,崩溃
这个代码居然能跑起来,崩溃
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->class Foo { const foo='bar'; public $foo='foobar'; const bar='foo'; static $bar='foobar'; } var_dump(foo::$bar); // static property var_dump(foo::bar); // class constant $bar = new Foo(); var_dump($bar->foo); // object property var_dump(bar::foo); // class constant
感觉很奇怪,我迷糊的很,怎么就呢过输出了??
------解决方案--------------------
为什么不能啊。
------解决方案--------------------
为什么不能啊。
------解决方案--------------------
除了 var_dump(bar::foo); // class constant 会出现 bar类未定义,其余都正常啊。你是怎样认为的?
------解决方案--------------------
反正跑起来了
------解决方案--------------------
1. 变量名区分大小写
1
2 $abc = 'abcd';
3 echo $abc; //输出 'abcd'
4 echo $aBc; //无输出
5 echo $ABC; //无输出
2. 常量名默认区分大小写,通常都写为大写
(但没找到能改变这个默认的配置项,求解)
3. 函数名、方法名、类名 不区分大小写
但推荐使用与定义时相同的名字
1
2 function show(){
3 echo "Hello World";
4 }
5 show(); //输出 Hello World 推荐写法
6 SHOW(); //输出 Hello World
class cls{
static function func(){
echo "hello world";
}
}
8 Cls::FunC(); //输出hello world
4. 魔术常量不区分大小写,推荐大写
包括:__LINE__、__FILE__、__DIR__、__FUNCTION__、__CLASS__、__METHOD__、__NAMESPACE__。
5. NULL、TRUE、FALSE不区分大小写

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to completely uninstall Win11XboxGameBar? Xbox GameBar is the game platform that comes with the system. It provides tools for game recording, screenshots and social functions. However, it takes up a lot of memory and is not easy to uninstall. Some friends want to uninstall it, but there is no way. How to completely uninstall it, let me introduce it to you below. Method 1. Use Windows Terminal 1. Press the [Win+X] key combination, or [right-click] click [Windows Start Menu] on the taskbar, and select [Terminal Administrator] from the menu item that opens. 2. User Account Control window, do you want to allow this app to make changes to your device? Click [Yes]. 3. Execute the following command: Get-AppxP

Concepts and instances of classes and methods Class (Class): used to describe a collection of objects with the same properties and methods. It defines the properties and methods common to every object in the collection. Objects are instances of classes. Method: Function defined in the class. Class construction method __init__(): The class has a special method (construction method) named init(), which is automatically called when the class is instantiated. Instance variables: In the declaration of a class, attributes are represented by variables. Such variables are called instance variables. An instance variable is a variable modified with self. Instantiation: Create an instance of a class, a specific object of the class. Inheritance: that is, a derived class (derivedclass) inherits the base class (baseclass)

Class is a keyword in Python, used to define a class. The method of defining a class: add a space after class and then add the class name; class name rules: capitalize the first letter. If there are multiple words, use camel case naming, such as [class Dog()].

jQuery is a classic JavaScript library that is widely used in web development. It simplifies operations such as handling events, manipulating DOM elements, and performing animations on web pages. When using jQuery, you often encounter situations where you need to replace the class name of an element. This article will introduce some practical methods and specific code examples. 1. Use the removeClass() and addClass() methods jQuery provides the removeClass() method for deletion

When writing PHP code, using classes is a very common practice. By using classes, we can encapsulate related functions and data in a single unit, making the code clearer, easier to read, and easier to maintain. This article will introduce the usage of PHPClass in detail and provide specific code examples to help readers better understand how to apply classes to optimize code in actual projects. 1. Create and use classes In PHP, you can use the keyword class to define a class and define properties and methods in the class.

In today's era of rapid technological development, programming languages are springing up like mushrooms after a rain. One of the languages that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Fix "TouchID Login" Issue on MacTouchBar Using Safari Icon Force the Touch Bar to restart will fix the issue: Open ActivityMonitor on your Mac, which is located in the /Applications/Utilities folder, or you can use Spotlight by pressing Command+Spacebar and Type ActivityMonitor and go back to launch it Use the search function of Activity Monitor and search for "Touch" Select "TouchBarServer" and then click the (X) Exit button in the Activity Monitor toolbar Select "Force Quit" to force

Laravel is a popular PHP framework that is highly scalable and efficient. It provides many powerful tools and libraries that allow developers to quickly build high-quality web applications. Among them, LaravelEcho and Pusher are two very important tools through which WebSockets communication can be easily implemented. This article will detail how to use these two tools in Laravel applications. What are WebSockets? WebSockets
