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.
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.
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.)
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.
Advanced search and replace allow you to find and replace characters within your code.
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.