PHP – Time and Date Functions
The time() and date() functions allow you to add time data to your applications. Time() provides the seconds since Unix Epoch (January 1, 1970) which is useful for basic timing in your application. The date() […]
The time() and date() functions allow you to add time data to your applications. Time() provides the seconds since Unix Epoch (January 1, 1970) which is useful for basic timing in your application. The date() […]
Text transformation in PHP is useful not just for esthetics, but to also make sure that data is uniform when dealing with databases and such. strtolower() https://www.php.net/manual/en/function.strtolower.php https://www.w3schools.com/php/func_string_strtolower.asp strtoupper() https://www.php.net/manual/en/function.strtoupper.php https://www.w3schools.com/php/func_string_strtoupper.asp ucfirst() https://www.php.net/manual/en/function.ucfirst.php https://www.w3schools.com/php/func_string_ucfirst.asp ucwords() […]
The explode() function allows you to turn a String into an Array based on a separator you define. explode() https://www.php.net/manual/en/function.explode.php https://www.w3schools.com/php/func_string_explode.asp explode.php
The var_dump() function allows you to see what a variable’s data type is, and what it’s value is. var_dump() https://www.php.net/manual/en/function.var-dump.php https://www.w3schools.com/php/func_var_var_dump.asp varDump.php
The strpos() function allows you to parse strings in PHP. strpos() https://www.php.net/manual/en/function.strpos.php https://www.w3schools.com/php/func_string_strpos.asp strpos.php
The shell_exec() function allows you to send commands to the Command Line using PHP. You can use this for everything from pinging websites, to calling installed apps such as FFMPEG. shell_exec() also returns the results […]
The pathinfo() function allows you to turn a filepath into an Array and then interact with the keys of the Array. You can grab the Filename, Extension, Folder Name and Basename. pathinfo() https://www.php.net/manual/en/function.pathinfo.php https://www.w3schools.com/php/func_filesystem_pathinfo.asp pathinfo.php
The in_array() function allows you to check if a value is stored with an Array. This can be used for things such as creating an array of which states a company ships products to. in_array() […]
If you allow you users to upload files to your web server you will probably want to create some restrictions. You can block uploads based off of file size, extension, or if a filename already […]
With an HTML form and PHP you can upload files to your web server. When you use $_FILE in PHP you are able to access information about the file stored in the $_FILE array. Prerequisites: […]
The isset() function in PHP checks to see if the value of a variable has been set. this can be useful in applications that allow users to login, or make sure that variables are actually […]
The glob() function in PHP allows you to search folders and put the results into an array based on basic filtering. glob() https://www.php.net/manual/en/function.glob.php https://www.w3schools.com/php/func_filesystem_glob.asp glob.php glob.php (with Image Embed)
$ Session Variables allow you to set Variable Values that can be accessed across all pages that your user goes to in your PHP Web Application. You must use session_start() on all pages that will […]
You can send Variable Names and Values using hyperlinks to PHP Scripts. This is an easy way to send variable data, but is incredibly insecure. To send a variable to a PHP script add ?variable_name=variable_value […]
Sending data to PHP from an HTML form is easy.
You can use PHP to redirect visitors to your web page to different pages automatically. This can be good for maintenance tasks and for marketing tracking.
Cookies allow you to set variables that are persistent between multiple visits to a website.
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; […]
The Print Function in PHP allows you to print text to dynamically create a web page. It’s important to understand that what you see in a web browser is different then what you would see […]
The PHPinfo() function prints out a report of al of the PHP configurations and settings for your server. <?php phpinfo(); ?>
You need to name your PHP files with a .php extension for them to work on your server. Past this you use the PHP Tags to trigger scripts within a web page. <?php print “Hello […]
Shared hosting is an easy way to deploy PHP code especially if you are new to technology. To run PHP on your own server you need to be able to build, configure and maintain a […]
You can use basic ASCII Text editors to write PHP code. You simply need to save the file with the .php extension.
Coding languages like all software has versions. These versions offer improvements, and changes over time. This means that functions that work in some versions do not work in others. So you need to verify which […]
To learn PHP you’ll need a LAMP server of some sort, a text editor, and a good study guide. I highly recommend buying a book because it’s an excellent UI while learning a language.
PHP is great for being able to easily create web apps that work. The problem is that it also easy to create code with major vulnerabilities that is a mess to read and try to […]
Why should you learn PHP when there are two many “better” languages available? It’s easy to learn. You can build practical web apps within a week of starting. Finally a huge number of legacy web […]
PHP is a Hypertext Preprocessor. This essentially means that PHP dynamically writes web pages for you. So it can query a database and print a report from it, or change CSS and such based on […]