PHP – Code Reuse – include
Using includes you can reuse the same code in multiple scripts.
Using includes you can reuse the same code in multiple scripts.
You can send emails directly from PHP scripts using the mail() function. You need to have a local email server setup to do this, to to learn it’s best to use a shared hosting account […]
By turning a file into an array you can work with the data within it as you would a standard array.
You can write variables to a file with file_put_contents(). If the file pointed to does not exist it will be created. By adding FILE_APPEND this will append data to the created file, if not the […]
Multidimensional delays are when you use Arrays as values for Arrays.
The foreach() function can turn Named Keys into variables just like it does array values.
The foreach() function allows you to loop though an array to process the values as variables.
You can sort arrays by key with ksort() and krsort().
The sort() and sort() functions allow you to sort arrays alphabetically.
Naming Keys in Arrays makes it easier to verify you are interacting with the appropriate data in an array.
Arrays allow for a variable to have multiple values. This gives you the ability to create lists of names, and be able to sort them easily. Also it allows you to have values from a […]
Do While Loops perform one iteration before a condition is tested.
While loops allow you to repeat code while a condition remains true.
For loops are ways to repeat specific code based on whether a condition continues to be true.
Logical Operators allow you to use AND or OR in comparisons for Loops and If Statements.
Comparison Operators allow you to compare variable values against values to determine whether an event should trigger. You use Comparison Operators in Loops and If Statements.
switch Statements allow you to allow events to happen based on specific values for variables.
elseif statements allow you to check to see if any of a number of conditions are true before failing out to the else in an if statement.
If Else Statements allow for code to run if a condition is true, but have different code run of a condition is false. <?php $age = 15; print “Your Age is $age”; print “<br>”; […]
If Statements allow you to trigger code if specific conditions are met. <?php $age = 20; print “Your Age is $age”; print “<br>”; if ($age < 18) { print “you too YOUNG”; } ?>
Commenting code allows you to add notations to you script to explain why it was written how it was. You can also use commenting to keep specific code from running during troubleshooting. <?php /* […]
Since Variables in PHP do not need to be declared you can run into issues such as trying to add a String to an Int. You also may have issues if you misspell a variable. […]
Variables in PHP can be set without needing to be declared. <?php $string = “Hello World”; $int = 1; $float = 2.2; print “<h1>String</h1>”; print $string; print “<h1>Int</h1>”; print $int; print “<h1>Float</h1>”; print $float; […]