php类名大小写问题
本地开发时,本地环境对类名不区分大小写,比如:new Dog() 和new dog()是一样的,
但是公司线上对这种是区分的,会报错。
请问这个东东怎么设置,实在php.in里面设置么?
回复内容:
本地开发时,本地环境对类名不区分大小写,比如:new Dog() 和new dog()是一样的,
但是公司线上对这种是区分的,会报错。
请问这个东东怎么设置,实在php.in里面设置么?
1.php 中
类,方法名,函数名不区分大小写
变量,常量区分大小写
2.win下目录不区分大小写, Linux 下目录区分
因此检查下你的代码,是否有目录名称
ps:强烈建议,统一大小写,不要随性,不然小心被人打死????
1、要注意代码规范,要么都大写,要么都小写,建议遵守 PSR 规范
2、是否区分大小写是跟文件系统有关系的
简单来说,win、mac 默认的文件系统都是不区分的
linux 默认的文件系统是区分
@悲惨的大爷 说的对~ 顶一个
此外,建议代码遵循PSR-1, PSR-2的规范,这样可以直接用php-cs-fixer
这个神奇的工具来自动修复代码编码规范。
参考: https://phphub.org/index.php/topics/547
PHP中有个东西叫做PSR规范。
有了这个规范可以做好多的事情。
像是什么自动加载了等等。
因此建议使用规范去命名。
题主遇到的问题应该是本地开发环境是win的,win的目录是不区分大小写的,因此在自动加载的时候能找到文件。而服务器可能是Linux的,Linux目录是区分大小写的,因此可能找不到了类文件。
最后再次建议,看一下PSR规范。
这个其实主要是系统的问题,Linux系统上是区分大小写的
这是规范问题。PHP有些地方不分大小写,但是自己要分。因为Linux目录是分大小写的。

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

AI Hentai Generator
Generate AI Hentai for free.

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

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
