“The digital revolution is far more significant than the invention of writing or even of printing.” - Douglas Engelbart

According to recent studies, we’re spending more and more time in front of screens. We now spend an entire day of every week on our smartphones.

Computers, TVs, and smartphones have revolutionised the way we live.

So how can we get the most out of them?

PHP is an easy-to-use programming language. It’s used in web development to programme web apps and code websites and has a number of useful features. Tags, hosting, resizing an image, etc., there are plenty of things you can learn to do with PHP programming.

In this article, we're going to look at what PHP is, why you should use it to display images, the code you'll need to display images, and how to create and display PHP images.

What is PHP?

Before we start explaining anything, we need to understand what PHP is. PHP is a programming language that was created in 1994 by Rasmus Lerdorf and can be used to create dynamic websites. There’s no need to be a web designer, programmer, or developer to start using it. PHP is famous for just how accessible it can be after just a few hours of training.

How do you programme in PHP?
All programming looks like nonsense if you don't know how to code. (Source: Pexels)

PHP is an open-source scripting language. This means that it can be freely used and modified by anyone. This is why a whole community grew around the language. Enthusiastic coders took joy in adding functionality right from the start. That’s how we ended up with seven versions of PHP. Special characters, algorithmic image sources, jpeg formats, regular expressions, etc. PHP is a rich language.

But what makes scripting with PHP different?

There are plenty of programming and scripting languages that can be used in web development, web applications, and web programming. Java, C++, JavaScript, Python, HTML, etc. There are plenty of ways to get a computer to understand what you want to do.

PHP allows you to create dynamic websites. In other words, the pages created with this programming language will display differently depending on who opens it. This functionality is very useful for creating things such as member areas.

Whether it’s learning about managing databases, development environments, HTML, syntax, script, command lines, server side, or HTML pages, learning to code with PHP requires work. However, you can get the basics down quite quickly.

Why Display or Create a PHP Image?

PHP was just a way for its creator to see how many people were looking at his CV on his website. Bit by bit, users developed functions for this programming language. Since it was free to use, programmers had a field day!

How do you make a website?
If you want to build a website, you should learn a bit of programming. (Source: Free-Photos)

Today, PHP is known for creating websites but it can also be used to create images and text.

The images are written into the PHP code and interpreted by web servers. This is how the language works. That said, the images do need to be stored in a PHP file.

Creating or displaying an image can make a website look better. Many PHP developers use it to simplify lines of code and save time.

Find out how you can use PHP with WordPress.

The Code for Adding a PHP Image

To add images to your website or project, the PHP language could be useful. This programming language isn’t just for creating web pages. You can also use it to add images to your site.

How do you code in PHP?
Code has to be written to the letter or it won't work. (Source: Pexels)

There are two different ways to do this. The first involves using the web page itself. Instead of a web page, you just need to include the image’s code. Then to see the image, you just need to add “.php” to make it appear on the page.

The second method involves storing the photo in a file.

In both cases, you need to know which code to make the site display the image. To do this, you need to start with the header.

The header is a code that allows the server to know that you want to display an image on the page. This means the image will display correctly.

The code for the header is as follows:


header (“Content-type: image/jpeg”);


This line of code will return a .jpg image and not an HTML page. Of course, in IT, there are many different image formats. You can also use .png, for example. These are of a higher quality and better for photos. To insert a .png image, you just need to replace “jpg” with “png”.

How to Create a PHP Image

Now that you know how to insert images, you should know how to use an image and put it into PHP code.

Once you’ve saved and named your image, what can you do with it?

How do you create a PHP file?
Make sure you have a clean and organised workspace when you're programming. (Source: StartupStockPhotos)

The previous code is just the beginning. It’s not the whole thing. You’ve just told the server that you’re going to display an image and not an HTML page. You’ve not told them which image you want to display. To insert an image, you can create one or use an existing image.

If you want to create an image, you’ll need to use the “imagecreate” function. This allows you to decide the size of your image. Thus, you’ll write the height and width as follows:


header (“Content-type: image/png”);

$image = imagecreate(300,100);


The term “$image” indicates that the data is variable. This means it can be changed. In this case, the image is 300 pixels wide and 100 pixels high. You can add information about the image.

If you want to use an image that’s already been saved, you just need to use the “imagecreatefromjpeg” or “imagecreatefrompng” functions. Let’s image we have a file named “myphoto.jpg”. You’ll need to use the code as follows:


header (“Content-type: image/jpeg”);

$image = imagecreatefromjpeg(“myphoto.jpg”);


Don’t forget to close the PHP code with “?>”.

Find out more about the advantages of PHP.

How to Display a PHP Image

You haven’t finished coding yet. The server has all the information about the image but it doesn’t know what it needs to display. The image is contained in the code but you can’t see it on the site. In this case, you need to add the last line using the “imagejpeg” or “imagepng” functions.

The code will be as follows:


header (“Content-type: image/jpeg”);

$image = imagecreatefromjpeg(“myphoto.jpg”);



In this case, the image will be directly displayed on the site. To display it on another page, you’ll need to use the HTML code <img src= “myphoto.php” />.

You can also save a photo or image without displaying on the site. In this case, you can use the “imagejpg” or “imagepng” function followed by the image name and folder name. This script will indicate to the server to save the file and not display it:


header (“Content-type: image/jpeg”);

$image = imagecreatefromjpeg(”);

imagejpg($image); (“myphotos/myphoto.jpg”);


The image will be saved in the “my photos” folder.

In this case, you don’t need the header function because you’re dealing with just an image and not a website. You’re just saving the image. You can display it using the following code:

<img src= “myphotos/myphoto.jpg”/>

You now know the PHP functions needed to display an image. There are other functions for adding text to the images you add, but we’ll save that for another day.

You can always practise by creating your own website. You learn from making mistakes.

If you need more help, you can always get tutorials and learn PHP from a tutor on Superprof. In fact, you can get tutorials on all types of object-oriented programming, PHP scripts, MySQL, Perl, Apache, Zend, or server-side scripting.

How To Learn PHP

If you are new to PHP, then there are various ways you can learn about using the language.

Learning PHP With Superprof

Superprof lets you search through a wide database of tutors. All you need to do is enter your postcode and the subject you’re looking for a tutor for, and you’ll be shown all the available tutors in your area, as well as those offering remote tuition.

There are three types of tutorials available on the platform: face-to-face tutorials, online tutorials, and group tutorials and each type has its pros and cons.

Face-to-face tutorials are usually the most expensive but they're also the most cost-effective since you'll be the only student in the class and the tutor can focus entirely on you.

Online tutorials tend to cost less since the tutor doesn't have to worry about their travel costs to and from the student. While these aren't ideal for subjects that require a hands-on approach, they can be really effective for technical subjects like IT.

Group tutorials are usually the cheapest per hour since the cost of the lesson is shared amongst all of the students in attendance. Of course, this does mean that you'll get less personal attention from your tutor.

Don't forget that a lot of the tutors also offer the first hour of tutoring for free. You can use this time to see if you get along with them if their teaching approaches are right for you, and discuss what you want and expect from your private tutorials.

Alternatively, you can opt for classes at an institution near you.

PHP And Web Development Courses

Cardiff University - PHP3 - PHP Web Application Development

"Thursdays from 18:00 to 21:00 plus 1 Saturday Day School

Duration 12 weekly meetings plus 1 Saturday Day Schools
Tutor Christopher Maggs
Course code COM19A5213A
Fee £450
Concessionary fee

This course introduces object oriented PHP and the use of software design patterns for practical web application development.

The course covers development of PHP classes and methods in order to create and maintain web applications. It covers the separation of the different parts of a web application and their relationships through object oriented programming and demonstrates their use in practical web development.

This course is ideal for the student who already has some knowledge of the PHP programming language.

Learning and teaching

This module includes a mix of traditional lectures and laboratory sessions.

The course will teach the fundamentals of Object Oriented programming applicable to PHP and will cover the use of Classes, Methods, and their relationships.

It will cover the generation of Objects through class instantiation, inheritance and extending classes. This will be achieved through a number of individual projects requiring some level of PHP development that will be covered during the lessons.

The course will continue with examples of typical software design patters that use OO style programming to achieve a maintainable web application, and will discuss the advantages / disadvantages of different methods.

The secondary purpose of this section will be for the student to decide which style they will use for the final part of the course.

The course will then provide the opportunity for each student to select a suitable web application and follow their chosen design method to generate their own functional web application. Students will be given the opportunity to either use a pre-existing template or to use their own time to create a more personal bespoke application.

Coursework and assessment

To award credits we need to have evidence of the knowledge and skills you have gained or improved. Some of this has to be in a form that can be shown to external examiners so that we can be absolutely sure that standards are met across all courses and subjects.

During the course, you will be given assignments to be submitted to the course tutor. At the end of the course, there will be a class test.

The most important element of assessment is that it should enhance your learning. Our methods are designed to increase your confidence and we try very hard to devise ways of assessing you that are enjoyable and suitable for adults with busy lives.

Reading suggestions

PHP Object Oriented Solutions David Powers / Friends of Ed
Practical Web 2.0 Applications with PHP Quentin Zervaas / Apress"

Birkbeck University London - Web Programming Using PHP

"Fee £775

This course covers the PHP skills required to design robust dynamic websites supporting user interaction. The focus is on good programming practice, by writing efficient, well-documented code that can be easily understood by colleagues. Topics include: PHP syntax (variables, control structures, functions); managing and manipulating data in external files; processing submitted form data (validating, displaying data and redisplaying the form); security; cookies and session management; authentication; error handling.

Prerequisites: Introduction to Web Authoring or equivalent; Problem Solving for Programming or some knowledge of basic programming concepts.

This short course can be taken as a stand-alone course or it may be available as part of a Certificate of Higher Education.

Entry requirements

Most of our short courses have no formal entry requirements and are open to all students. You may have to fulfil specific prerequisites for some intermediate-level or advanced-level courses, but these will be specified where relevant.

This short course has prerequisite(s). If you try to enrol on this short course without completing the prerequisite(s), you will not be able to complete your enrolment. Please contact us if you would like further information."

Online Resources For Learning PHP

If you are wondering how such a complicated subject can be taught without someone explaining it face to face, then you may be surprised when you follow our advice and check out these online resources because they really are descriptive and self-explanatory. No questions needed!

Of course, if you do have questions though or if you simply prefer the human to human contact then you can easily find a tutor who can work with you either face to face or via Skype/email.

Code Academy

Code Academy Pro is one of the principal avenues for learning to code online. You can access their premium service which includes: quizzes, portfolio-building projects, and customized paths— it is your blueprint for learning new skills.

Monthly payments for pro members cost £31.99 amounting to £383.88 however you can cut down this price to just £191.88 - a saving of £192.00 - by paying upfront for the year and getting instant access to all the website's great features.

Take a look at the Learn PHP syllabus offered by Code Academy, a 20-hour long course.


Why Learn PHP?

PHP is a widely used server-side programming language that’s become increasingly fast and powerful over the years. PHP works well with HTML and databases, making it a great language for anyone interested in building dynamic web applications.

Take-Away Skills

In this course, you’ll be exposed to fundamental programming concepts in PHP.

Upcoming Releases

We’re building new and exciting content for this course, keep an eye out for this fresh content coming soon!

Note on Prerequisites:

Some basic HTML is helpful before taking this course.


1 Getting Started with PHP
Introduction to PHP
Interactive Lesson
Introduction to PHP
Multiple Choice Quiz

2 Learn PHP Variables

3 Introduction to Functions in PHP

4 PHP Built-in Functions

5 Learn PHP Arrays

6 HTML Form Handling in PHP

7 Conditionals and Logic in PHP

8 Loops in PHP"

Guru 99

Guru 99 is another site which offers PHP language lessons - this time it's "PHP Tutorial for Beginners: Learn in 7 Days". So, if learning a new language (as it were) in just one week sounds like an idea, then go and visit their website and check out all the details and terms and conditions.

For now, here is a brief overview of the course on offer.

"Training Summary

PHP is the most popular scripting language on the web. Without PHP Facebook, Yahoo, Google wouldn't have exist. The course is geared to make you a PHP pro. Once you digest all basics, the course will help you create your very own Opinion Poll application.

What should I know?

Just a full form of PHP would be enough to learn this course. This tutorial is designed for beginners with little or no PHP experience.

Training Syllabus

PHP Fundamentals

Tutorial What is PHP? Write your first PHP Program
Tutorial XAMPP & Netbeans installation
Tutorial Data Types, Variables and Operators
Tutorial Comments, Include & Require
Tutorial Arrays in PHP

Lets introduce some Logic!

Tutorial PHP Control Structures: If else, Switch Case
Tutorial PHP Loop: For, ForEach, While, Do While
Tutorial How to create PHP strings and why to use strings?
Tutorial Functions in PHP
Tutorial PHP Forms
Tutorial Cookies & Sessions
Tutorial File Processing
Tutorial Error Handling
Tutorial Regular expression

Advance Stuff

Tutorial MAIL
Tutorial Database Access
Tutorial OOPS in PHP
Tutorial Using Date
Tutorial Security functions
Tutorial XML,DOM, Parsers with PHP

Your First PHP project!

Tutorial Create an Opinion Poll Application using PHP
Tutorial How to create Ajax based PHP application
Tutorial MVC Framework Tutorial: CodeIgniter Example
Tutorial CakePHP Framework Tutorial for Beginners


Tutorial PHP vs JavaScript: Must Know Differences
Join PHP Live Project Training
Check PHP Interview Questions and Answers"

It's never been easier to learn something new!

Need an Information Technology tutor?

Enjoyed this article?

0 vote(s)