Skip to main content

Posts

PHP Advanced

PHP Date and Time The PHP date() function is used to format a date and/or a time. The PHP Date() Function The PHP date() function formats a timestamp to a more readable date and time. Syntax date(format,timestamp) Parameter Description format Required. Specifies the format of the timestamp timestamp Optional. Specifies a timestamp. Default is the current date and time A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred. Get a Date The required format parameter of the date() function specifies how to format the date (or time). Here are some characters that are commonly used for dates: d - Represents the day of the month (01 to 31) m - Represents a month (01 to 12) Y - Represents a year (in four digits) l (lowercase 'L') - Represents the day of the week Other characters, like"/", ".", or "-" can also be inserted between the characters to add additional formatting. The exa

PHP Forms

PHP Form Handling The PHP superglobals $_GET and $_POST are used to collect form-data. PHP - A Simple HTML Form The example below displays a simple HTML form with two input fields and a submit button: Example Name: E-mail: When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php". The form data is sent with the HTTP POST method. To display the submitted data you could simply echo all the variables. The "welcome.php" looks like this: Welcome Your email address is: The output could be something like this: Welcome John Your email address is john.doe@example.com The same result could also be achieved using the HTTP GET method: Example Name: E-mail: and "welcome_get.php" looks like this: Welcome Your email address is: The code above is quite simple. However, the most important thing is missing. You need to validate form data to protect

PHP Basics statements and loops

PHP if...else...elseif Statements Conditional statements are used to perform different actions based on different conditions. PHP Conditional Statements Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do this. In PHP we have the following conditional statements: if statement - executes some code if one condition is true if...else statement - executes some code if a condition is true and another code if that condition is false if...elseif...else statement - executes different codes for more than two conditions switch statement - selects one of many blocks of code to be executed PHP - The if Statement The if statement executes some code if one condition is true. Syntax if (condition) { code to be executed if condition is true; } Example Output "Have a good day!" if the current time (HOUR) is less than 20: PHP - The if...else Statement The if...else state

PHP Basics

PHP Tutorial PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. PHP 7 is the latest stable release. Easy Learning with "PHP Tryit" With our online "PHP Tryit" editor, you can edit the PHP code, and click on a button to view the result. Example PHP Introduction PHP code is executed on the server. What You Should Already Know Before you continue you should have a basic understanding of the following: HTML CSS JavaScript If you want to study these subjects first, find the tutorials on our Home page. What is PHP? PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use PHP is an amazing and popular language! It is powerful enough to be at the core