Some questions regarding to PHP

hello

just trying to sort my mind out, i am currently confuse about the new php versions; here is my questions: i’m a beginner (just to let you know)

  1. should i learn php 5.6 or dive in straight to learn php 7?
  2. do php 5.6.x version backwards compatible to php 7? what version is compatible to php 7? if there is…
  3. do they have different fundamentals to learn on both version of php 5.6 and php 7?
  4. should i just stick to php 7?

thank you for you time :slight_smile:

No.
This answer renders your other questions obsoleted.

Frankly, it’s the same language. The difference between the two is like 0.001%
So just learn PHP.

1 Like

that is why i have mentioned that i am a beginner, thank you for your time and your reply :slight_smile:

so the basic fundamentals of php are all the same, and that version of php 7 is just a new set of features added to the php fundamentals is that what your saying? and why they calling it backwards compatible to php 7 with the old versions of php5.3.x and up?

thanks in advance

I am saying that you better don’t waste your time with these questions. You will need years to get the difference. So better start learning programming basics already.

2 Likes

yes, i am already started learning the basic core fundamentals of php, just getting head straight about php versions… oh, well… thanks for the advice, i should focus more on learning, i will stop questioning now the versions… thanks.

When you’re looking through any tutorials, if you see any function names starting with “mysql_”, steer well clear of them as they are using the mysql_* extension which was depreciated in 5.6 and removed from 7.0

Any scripts requiring access to a MySQL server should use either the mysqli_* extension (MySQL Improved) or PDO. Whenever you’re using any submitted data or data supplied by another script or array ALWAYS use prepared statements. Even if the data isn’t submitted by the user, still use prepared statements, so that if you change the source of the data to one submitted by the user and you’'ll still be protected from SQL Injection attacks

Also when it comes to hashing of passwords, don’t use md5 as it has been rainbow tabled to death, make use of PHP’s built in functions for dealing with password hashing

2 Likes

namely: password_hash()

doc: http://php.net/manual/de/function.password-hash.php

1 Like

No, If you are a beginner then go for php 5.6 after learning 5.6 go for 7 version of php

1 Like

I’m curious to hear your reasons why?

One reason is that some host providers might not have moved to php 7 yet. Otherwise, for a beginner, I don’t see any real point in learning a version that will soon be depreciated.

1 Like

Also, is PHP 7 all that different than PHP 5.6 for a person just starting out to learn PHP? It’s the same language - just with some additions and improvements.

3 Likes

I agree with the others, just learn PHP (period). That is, PHP, the latest.

But I will also say, many cheap hosts are not on PHP 7 yet, which means if you are going to build stuff and stick it on a cheap host, you may want to make yourself aware of some of the primary changes between 5.6 and 7.

It’s not a lot, some of it is just syntax sugar and shortcuts. So go ahead and study PHP, meaning PHP “the latest one”. But then at some point take a step back and read a two or three page document that summarizes the new features of 7 so you know what they are.

1 Like

A good PHP starting point is to either set the following at the top of a page or better still to set the parameters in php.ini

<?php 
error_reporting(-1);
ini_set('display_errors', 'true');

The above will set the maximum error reporting and also display the errors to the screen

Check the very comprehensive online manual to learn how to not show online users potential security risk errors and to use the errors log file.

http://php.net/manual/en/function.error-reporting.php

1 Like

thought I would mention here also that there are several big speed a file size advantages with the newer versions of PHP @08ski11s, I think your server should be equipped with something newer than 5.6…

1 Like

I regularly read what this lad publishes, he talks about the performance improvements with the new versions of PHP http://www.hongkiat.com/blog/php7/

1 Like

Currently i am setting up a local virtual server using ubuntu xenial or trusty LTS for a dev environment in my computer, i will create separate 2 containers each with different versions of php which is 5.6 and 7 for testing purposes etc., thank you for the advice :+1:t2::blush:

1 Like

Vagrant Vagrant, every day!

Or maybe Docker.

1 Like

Better is to go with 7, I am not recommending as I am also the beginner :eyebrows: but regarding optimization for your future project this version would be nice.

1 Like

yes my current setup is Ubuntu Xlts >> Docker >> Swarm :slight_smile:

There is not too much differences between all these as they all are same. So, just learn to focus PHP.

1 Like