PHP programmer can do Python Programming?


I am a PHP programmer and I just want to confirm that if I want to change my career to Python programming then Will it be easy to learn Python?

The code is similar as you do not need to worry about variable types and it also has lots of functions.

Why not have a go and see how you get on. What is easy for one person probably isn’t for another.

1 Like

Python is a very simple language to learn.
in PHP to print hello world this is the code that used between html tags right
<?php echo 'Hello World'; ?>

public class HelloWorld {
    public static void main(String[] args) {
       System.out.println("Hello, World"); }}

But in python printing hello word is
print "hello world"

its that simple

Python is actually a bit different than PHP. PHP allows procedural coding while Python does not. You also don’t declare classes and methods like you would with PHP using Python. It’s a bit different. You also have constants and varibals being called in the same way while in PHP, the $ indicates variables.

So jumping from PHP to Python, you will notice a lot of things are different. Python is usually used for system type of things while PHP is a web based language.

I wrote some code for a humidity/temperature sensor with a Rasberry Pi.

Obtained the data and saved it with Python

Read the data and displayed it in a graph with JavaScript

Made the webpage links dynamic with php

1 Like

What makes you say that? :confused:

Well, PHP is written mostly in procedural. Python uses classes and methods. I mean PHP does also allow OOP, but a large majority of codes you’ll find all over the Internet is usually written in procedural. Though, I do see OO every so often, but not as much as procedural.

In Python, I believe it’s all OO. I remember dipping my dirty fingers in Python once and my face almost exploded. I couldn’t understand much of it because a lot of C derivatives use something like

public function blahblah() {
    ... Whatever here

While Python is something like

def blahblah():
    ... Whatever here

It’s very weird. I haven’t dipped my dirty hands (full hands) in Python yet, but I will sooner or later. I want (this is what you get when you’re on a mobile phone) to understand what the hype is about. And why people who use Python bash on PHP users so much. And it’s weird because I don’t see Ruby or Java users bash on PHP. Just only Python users. And how do I know this? Well, when someone generally bashes on PHP, they tend to list what they like and love after their statements. And Python usually shows up 90% of the time after that rebuttal.

I mentioned a year or so ago I thought Python was the new “in” language and had some quite angry replies. I do not do a lot of programming but from what I have seen it has taken off in the last three years and people are using it for everything. You can even use it for websites if you feel so inclined !

1 Like

The sad truth is, it was never really “meant” for the web. That’s why you need frameworks ontop of Python in order for Python to actually work on the web. If it’s just the language itself, people can argue back and forth what they “think” is the best language. But what they should really focus on is what that language is generally “supposed” to be used for. People don’t think of it like this. They just think that their language is better and who has what user base and who doesn’t.

Python would be much suited for something like running a process in Linux or maybe even a repo that can be executed via the terminal. PHP would be more suited for generating dynamic content because that’s what it was built for. Imagine PHP users starting to be able to make a terminal repo and tried to compete with Python. The bashing would go the other way round simply because when a product expands to a new area, the new product usually has user bases that bash on older products. Sorry for straying off topic.

Going from PHP to Python will be a different feel. You may like it and you may not. It all depends on how flexible your learning curve is

^ This

Different languages have their own strengths and weaknesses. Analogous to the truth that a rip saw can be used to cut against the grain, using the “wrong tool” (i.e. language) can “work” but it won’t be the easiest or most efficient to use.

My admittedly mostly uninformed opinion is that PHP is primarily “web-centric” and Python is primarily “system-centric”

Can a PHP dev learn Python, sure, why not?

1 Like

I would be careful not to equate which programming styles a language is popularly used for with which styles it actually supports. Some of the reasons so much existing PHP code is procedural is that PHP is frequently a first language, and beginners tend not to start with OOP and the OOP features were not baked into the language from the beginning… it has evolved into a more OOP capable language over time.

I’m not sure what point you’re trying to make with the code examples here, other than show both languages have a different syntax. With Python you can declare stand-alone functions within a global scope, just as you can in PHP.

Regarding criticism, every language has it’s share of supporters and detractors. People bash PHP, they bash JavaScript, Java, probably Python (although I’ve not seen this as much), but it really depends which circles you hang out in. I always think of that quote from Bjarne Stroustrup: “There are only two kinds of languages: the ones people complain about and the ones nobody uses”.

It would be just as easy to say that PHP was never meant for building web applications (it wasn’t) but that doesn’t stop some large and complex apps being built with it. I’d agree with you that people tend to think ‘their’ language is better, and that you need to be pragmatic and choose languages based on their suitability for the task at hand (ironically, this is something many PHP programmers seem reluctant to do).

At the end of the day, I think you’d be hard pressed to find a task that PHP could do better or significantly easier than Python. In fact, in terms of mileage, you can make the argument that learning Python gives you more ‘bang for your buck’, as it’s more suitable to a wider range of non-web related tasks (scientific computing, for example).

Just in case I’m coming off as being pro-Python, I actually started out programming in PHP (for the web, at least). I’m just trying to correct a few misconceptions :slight_smile:


If you already know a programming language, learning Python won’t be very hard.

You could probably make a case for that in most second languages, as you’ll already be familiar with many of the concepts involved in programming.

Part of a course I studied computer languages and the one I had great trouble trying to learn was Prolog. It is nothing like any other language!


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.