Difference between PHP and Python

Posted under » PHP » Python » Django on 29 Jun 2021

Concatenate of strings is different in python. In python, you do this where goyay is an integer.

goyayurl = '/feels/'+ str(goyay) +'/'

In PHP we do this.

$goyayurl = '/feels/'.$goyay.'/';

However for python, you use . to concatenate commands eg.

c_title = a_title.replace('\n', ' ').replace('\\','\\\\')

MySQL update in PHP may look like this.

mysqli_query($dbhandle, "UPDATE consent SET answered = $question_id WHERE student_id=$study");

Where in django it may look like this

for consent in Consent.objects.filter(student_id=study):
 consent.answered = question_id
 consent.save()

In Python, greater than

Entry.objects.filter(id__gt=4)

In PHP the SQL is

SELECT ... WHERE id > 4;

Other examples of making queries

String filter Case-sensitive starts-with.

Entry.objects.filter(headline__startswith='Lennon')

In Php

SELECT ... WHERE headline LIKE 'Lennon%';

More »

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS