Python和PHP有哪些主要区别?

时间:2022-04-08 13:26:04

I know PHP a little. But Python is totally new for me. I only know it's something "similar", right? Or wrong? What are the differences I should know?

我知道PHP一点点。但Python对我来说是全新的。我只知道它是“相似的”,对吧?还是错的?我应该知道的不同之处是什么?

3 个解决方案

#1


15  

Here is a link to the python wikipedia. It highlights the main differences and the common elements: http://wiki.python.org/moin/PythonVsPhp

这是python*的链接。它突出了主要的差异和共同的元素:http://wiki.python.org/moin/PythonVsPhp

#2


14  

PHP is a language that's made for the web. You can make GTK and CLI applications with PHP, but it's mainly used for websites. Python is used for a lot of stuff like websites, webservers, game frameworks, desktop and CLI application, IDEs and a lot more.

PHP是一种为Web制作的语言。您可以使用PHP制作GTK和CLI应用程序,但它主要用于网站。 Python用于很多东西,如网站,Web服务器,游戏框架,桌面和CLI应用程序,IDE等等。

There's also a huge difference in the syntax. PHP has a syntax that's like C with curly braces for loops and whitespace is ignored. Python doesn't have curly braces, instead the level of indention of blocks of code are important.

语法也有很大差异。 PHP的语法类似于C,带有花括号的循环和空格被忽略。 Python没有大括号,而是代码块的缩进级别很重要。

Both languages are easy to learn. It just depends on what you want to do.

这两种语言都很容易学习。这取决于你想做什么。

#3


1  

One main difference is, that code formatting (indentation) influences your codes behaviour in Python. PHP is not interested in how you format your code.

一个主要区别是,代码格式化(缩进)会影响Python中的代码行为。 PHP对如何格式化代码不感兴趣。

Furthermore PHP may be able to produce applications outside of webservers and CLIs but is definitely aimed at those two environments while Python is more "all purpose".

此外,PHP可能能够在Web服务器和CLI之外生成应用程序,但绝对针对这两种环境,而Python更“全能”。

#1


15  

Here is a link to the python wikipedia. It highlights the main differences and the common elements: http://wiki.python.org/moin/PythonVsPhp

这是python*的链接。它突出了主要的差异和共同的元素:http://wiki.python.org/moin/PythonVsPhp

#2


14  

PHP is a language that's made for the web. You can make GTK and CLI applications with PHP, but it's mainly used for websites. Python is used for a lot of stuff like websites, webservers, game frameworks, desktop and CLI application, IDEs and a lot more.

PHP是一种为Web制作的语言。您可以使用PHP制作GTK和CLI应用程序,但它主要用于网站。 Python用于很多东西,如网站,Web服务器,游戏框架,桌面和CLI应用程序,IDE等等。

There's also a huge difference in the syntax. PHP has a syntax that's like C with curly braces for loops and whitespace is ignored. Python doesn't have curly braces, instead the level of indention of blocks of code are important.

语法也有很大差异。 PHP的语法类似于C,带有花括号的循环和空格被忽略。 Python没有大括号,而是代码块的缩进级别很重要。

Both languages are easy to learn. It just depends on what you want to do.

这两种语言都很容易学习。这取决于你想做什么。

#3


1  

One main difference is, that code formatting (indentation) influences your codes behaviour in Python. PHP is not interested in how you format your code.

一个主要区别是,代码格式化(缩进)会影响Python中的代码行为。 PHP对如何格式化代码不感兴趣。

Furthermore PHP may be able to produce applications outside of webservers and CLIs but is definitely aimed at those two environments while Python is more "all purpose".

此外,PHP可能能够在Web服务器和CLI之外生成应用程序,但绝对针对这两种环境,而Python更“全能”。