In this video, we'll discuss how to store a value in memory. We can then reuse this value in our subsequent code. There are two ways to store values: variables and constants.
Let's start with variables. To create a variable in PHP, we use the $ symbol followed by the variable name. Variable names can only consist of letters, numbers, and underscores. No other symbols, especially spaces, are allowed. Variable names can begin with a letter or underscore, but not a number.
Variable names in PHP are case-sensitive. Therefore, names with uppercase and lowercase letters will produce different results.
There are two commonly used naming formats in PHP. The first is the naming format used by older programming languages like C: snake_case. We write variable names in all lowercase, and if the name consists of multiple words, the words are separated using an underscore. Since PHP was created from the C language, in its early days, many programmers used snake_case to write PHP code.
However, programmers now also prefer to use camelCase, as this format is also widely used in other programming languages such as JavaScript, Java, and C#. To use camelCase, write the first word in all lowercase, then the second word, and so on, using the first letter in uppercase.
You are free to choose between snake_case or camelCase. The important thing is consistency. If you choose camelCase, it means you will use camelCase throughout your source code. Don't mix some snake_case and some camelCase, as it will be confusing.
For those who want to learn PHP more comprehensively, you can visit the link below:
https://skysencourse.com/coursedetail...
Basic PHP Tutorial Playlist:
• Tutorial PHP Dasar
На этой странице сайта вы можете посмотреть видео онлайн Variables and Constants – Basic PHP Tutorial #03 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Skysen Course 11 Апрель 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 1,270 раз и оно понравилось 28 зрителям. Приятного просмотра!