Author: admin
-
PHP File System
Working with Files in PHP Since PHP is a server side programming language, it allows you to work with files and directories stored on the web server. In this tutorial you will learn how to create, access, and manipulate files on your web server using the PHP file system functions. Opening a File with PHP fopen() Function…
-
PHP Include and Require Files
Including a PHP File into Another PHP File The include() and require() statement allow you to include the code contained in a PHP file within another PHP file. Including a file produces the same result as copying the script from the file specified and pasted into the location where it is called. You can save a lot of time…
-
PHP Date and Time
The PHP Date() Function The PHP date() function convert a timestamp to a more readable date and time. The computer stores dates and times in a format called UNIX Timestamp, which measures time as a number of seconds since the beginning of the Unix epoch (midnight Greenwich Mean Time on January 1, 1970 i.e. January 1, 1970 00:00:00 GMT…
-
PHP GET and POST
Methods of Sending Information to Server A web browser communicates with the server typically using one of the two HTTP (Hypertext Transfer Protocol) methods — GET and POST. Both methods pass the information differently and have different advantages and disadvantages, as described below. The GET Method In GET method the data is sent as URL…
-
PHP Math Operations
Performing Math Operations PHP has several built-in functions that help you perform anything from simple additions or subtraction to advanced calculations. You’ve already seen how to perform basic mathematical operations in PHP operators chapter. Let’s check out one more example: Example Every math operation has a certain precedence level; generally multiplication and division are performed before addition…
-
PHP Functions
PHP Built-in Functions A function is a self-contained block of code that performs a specific task. PHP has a huge collection of internal or built-in functions that you can call directly within your PHP scripts to perform a specific task, like gettype(), print_r(), var_dump, etc. Please check out PHP reference section for a complete list of useful PHP…
-
PHP Loops
Different Types of Loops in PHP Loops are used to execute the same block of code again and again, as long as a certain condition is met. The basic idea behind a loop is to automate the repetitive tasks within a program to save the time and effort. PHP supports four different types of loops.…
-
PHP Sorting Arrays
PHP Functions For Sorting Arrays In the previous chapter you’ve learnt the essentials of PHP arrays i.e. what arrays are, how to create them, how to view their structure, how to access their elements etc. You can do even more things with arrays like sorting the elements in any order you like. PHP comes with…
-
PHP Arrays
What is PHP Arrays Arrays are complex variables that allow us to store more than one value or a group of values under a single variable name. Let’s suppose you want to store colors in your PHP script. Storing the colors one by one in a variable could look something like this: Example But what,…
-
PHP Switch…Case Statements
PHP If…Else Vs Switch…Case The switch-case statement is an alternative to the if-elseif-else statement, which does almost the same thing. The switch-case statement tests a variable against a series of values until it finds a match, and then executes the block of code corresponding to that match. switch(n){case label1: // Code to be executed if n=label1 break;case label2: // Code…