Extras

Code Editors & IDEs

You can write PHP code in the text editor that comes with your operating system, such as Notepad on a PC or TextEdit on a Mac, but there are many advantages to using a code editor. Basic code editors are like text editors with some extra features that are designed to help programmers.

When you work a lot with a specific programming language, you should consider using an integrated development environment (IDE). An IDE is a code editor that is designed to both help you write code in a specific programming language, and find errors in your code.

Code Editors

Below, you can see some of the features that you will find in code editors such as Sublime Text, Visual Studio Code, and Atom.

Line numbers are displayed next to each line of code.

This helps because error messages usually state the line that an error was found on.

Most code editors also let you specify a line number and it will take you to that line of code.

Screen shot of code editor with the line numbers showing on the left of each line

Code folding allows the editor to close or expand individual code blocks.

When you have a long page of code, closing some of the code blocks can help you navigate it more easily.

Screen shot of code editor with code blocks collapsed and ellipses where they are closed.

Syntax highlighting shows different types of code in different colors. For example, operators and keywords, variable and function names, data types, and values are in different colors.

This helps you see when your syntax is incorrect and helps you scan your code for different types of names or values faster.

(And for HTML, tag names, attribute names, and attribute values can all be written in different colors.)

Screen shot of the a code editor demonstrating the different colours provided by code highlighting

Auto-completion provides a list of possible things you may be trying to type as you start typing them. It will also provide some of their permitted values, too.

Screen shot of code editor with auto-completion for String functions in PHP

Advanced search and replace allow you to find and replace characters within your code.

Code editor with search and replace tool replacing the word type with the words account_type

Integrated Development Environments (IDEs)

Integrated Development Environments are code editors with a deeper understanding of the programming language that you are writing in. The two most popular are:

In addition to the above features they offer the ability to:

  • Check for code errors and highlight issues such as incorrect syntax or values that are not allowed.
  • Highlight missing code and tell you if you try to use a variable, function, parameter, object, property, or method that is not declared or defined.
  • Step through code, which means running it one line at a time. After running each line, you can check values stored in variables or returned from functions.
  • Add breakpoints to stop the PHP interpreter running on a specified line of code.
  • Work across multiple files and point out where references to code in other files in the project may need updating.
  • Connect to a database so that the IDE can tell whether or not the data you are trying to work with exists in the database.