This is a short note that I created to refresh my memory on for the introduction to PHP and I hope to continue while I keep learning more about this serve side scripting language.
PHP also is known as Hypertext Pre Processor code executes on the server and the results return to the browser as plain HTML. The PHP files should have a “.php” extension. PHP can generate dynamic page content which allows the server to generate unique content each time the page is loaded. PHP can perform many tasks on files such as open, read, write, create, close files in the server as well as add delete, modify data in the database. It is also used to control user access and encrypt data.
Syntax
- The sript should start and end as <?php ?>
- The statements in PHP should end in ' ; ' sign ex: echo “Hello PHP”;
- PHP keywords (if, else, etc.) classes, functions, and user-defined functions are not case sensitive.
Ex: echo ✅ , right Echo ✅
However, all the variable names are case sensitive.
Ex: $test and $Test are not the same
Comments
These are used to let others understand the code better and for you to help remember easily what that part of the code does.
// - for a single comment
# - for a single comment
/* */ Multiple line comment
Variables
Variables are used to store data and start with a ‘$’ sign followed by the name. It is created when you assign a value for it. As stated above variables are case sensitive.
$temp = “Hello”;
$b = 35.3;
A variable must start with a letter or an underscore character and cannot start with a number.
Should only contain: A-z , 0-9 and _
Commonly used PHP String functions
PHP Numbers and Math
Following are some functions that can be used on Integers,
Floats, and Number Strings.
Next we’ll see some PHP functions that is used to perform simple
mathematical tasks.
PHP Constants
Constants are lot like variables that cannot change or be undefined.
They can be used across the script as they function in global scope. To create
a constant,
Define(name, value, case sensitivity)
You can also create constant arrays.
Ex: define( “FRUITS”[“Mango” ,”Peach”, ”Orange”] )
References
https://www.w3schools.com/php/default.asp
Authors Note
It's been a while since I last coded in PHP. But I always liked the language. w3schools has been the main site where I learned my basics and I created this short note referring to that site. If you need a more elaborate explanation it is the place to go. This article is mainly written as a quick read to refresh the memory.
No comments:
Post a Comment