Restarting with PHP - learning project

Hi guys,

As mentioned in my introductory topic, after quite a few years of absence I’m just now getting back into PHP.

In school I once had to do a learning project where I needed to build, from scratch, a webshop to learn many of the basics. Well, this was in 2007 - 2009. I can imagine that much has changed over the years.

I’m planning to redo this project to get back into it. Do you have any advice as to what changes in PHP I should look at? When I quiet I still had to salt my own passwords before hashing it. I already know about password_hash() and password_verify() and will be looking into those.

yours,
Bernhard

PDO…

If you are going to do any database work… use PDO.

1 Like

Well, there are many different ways to learn newer processes in PHP. If you want some general code examples and tutorials, you can look at these: WWW-Schools PHP
This is a handy site that covers just about everything code-wise. The actual code is sometimes not the best “form” and quite often not the way we would handle it here. But, they have a vast amount of examples to get you started. When you get stuck, post here and we can help.

And, I 100% agree with Whispers. PDO is the much more secure way to access databases. Much safer than MySQLi. (MySQL is no longer used. The Improved version is better, but, not secure as PDO.) PDO is fairly easy to learn. Here is a great link for that: PDO-The-Right-Way

Hope that gets you started… We will see you in your next post!

1 Like

If you are asking what changes have occurred in the php language that you will need to make to bring your code up to current php standards, there are migration sections in the php.net documentation that list the removed, backward incompatible, and deprecated features.

If you are asking about current programming practices to use, it would be more direct if you posted your code somewhere for it to be examined, either in the forum or on github.

For database implementation code, yes, use the much simpler and more consistent PDO extension, use prepared queries when supplying external/unknown data to the sql query statement, use implicit binding (supply an array of data to the execute method call), and use exceptions for database statement (connection, query, prepare, and execute) errors and in most cases let php catch and handle the exception, where it will use its error related settings to control what happens with the actual error information (database errors will ‘automatically’ get displayed/logged the same as php errors.) When making the connection using PDO, set emulated prepared queries to false, set the error mode to exceptions, and set the default fetch mode to assoc. Doing these things will result in the simplest implementation code and simplest sql query-build syntax. You will be able to eliminate a lot of database related code, rather than to convert it.

At the moment I do not yet have any code. It will be coming soon.

The last PHP version I worked with was 5.4 but did not use PDO back then. So I’ll be taking a look at that.

2 posts were split to a new topic: PDO vs Mysqli

You don’t have to follow all of it right away.

I was stuck using 5.4 at work all the way up to 2016 :frowning:

On small personal projects recently I’ve used the information from these sections:

Look for a recent “no-framework framework” tutorial and also try out a popular framework at the same time.

Sponsor our Newsletter | Privacy Policy | Terms of Service