简体   繁体   English

php 语法差异 unix vs windows

[英]php syntax difference unix vs windows

I made a project in PHP in windows.我在 Windows 中用 PHP 做了一个项目。 It was something like这就像

$item = [3, 5, 6];

It works splendid in windows.它在 Windows 中表现出色。 When i use the same code in linux, i get an error, unexpected [当我在 linux 中使用相同的代码时,我收到一个错误, unexpected [

So i try所以我尝试

$item = array(3, 5, 6);

Which is working.哪个有效。 Now my project is screwed because i developed in windows but actually need to run on linux.现在我的项目被搞砸了,因为我在 Windows 中开发但实际上需要在 linux 上运行。 Why is it not behaving the same on both OS and are there any other potential triping wires when it comes to coding PHP ?为什么它在两个操作系统上的行为不同,并且在编写 PHP 时是否还有其他潜在的绊脚线?

  • thanks谢谢

There is obviously no difference in syntax.语法上显然没有区别。

The PHP version on Linux must be older than PHP 5.4 since only since that version, the short array definer was introduced. Linux 上的 PHP 版本必须早于 PHP 5.4,因为自该版本以来,才引入了短数组定义器。

Old versions are problematic and you might not be able to run any newer libraries since most of them use [] to initialize arrays.旧版本有问题,您可能无法运行任何较新的库,因为它们中的大多数使用[]来初始化数组。

Nowadays, it's expected for you to run PHP 5.6 to have all the features that various libraries might need.如今,希望您运行 PHP 5.6 以拥有各种库可能需要的所有功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM