List/Grid PHP Subscribe RSS feed of category PHP
How to Embed PHP using Different Tag Types
In PHP language, there are some different types of tags to start and end the PHP script. There are four delimitation variants, all of which are introduced below: Default Syntax: The default delimiter syntax opens with “<?php” and ends with “?>” <?php echo "Text using the default syntax of tags."; ?> Short-Tags: These tags are known as short-tags because you are typing less for same result. The difference is…
How to Write Your First PHP Code
Under the label PHP you can learn basics, intermediate and advanced programming in PHP. If you are the beginner lets start with your first script in PHP. <html> <head> <title>First PHP Script</title> </head> <body> <?php echo "This is the text using PHP."; ?> </body> </html> In the above example there is a basic structure of HTML. In the body tag I used PHP code. To start…
How to validate date in PHP
Sometimes in the forms you want to validate the date via PHP functions to check whether date was in correct format or not. If you didn’t validate it, it may cause some issues in your code. To prevent such errors you should check the date format in PHP. To perform that use the checkdate() function in PHP. This function accomplishes the task of validating dates quite nicely. returns TRUE if…
How to Declare Dynamic Function/Constructor in php
In many cases you wanted to declare dynamic function which allows you to pass multiple parameters. Here is the example to demonstrate the dynamic function or constructor. Take an example of database connection class in which you want to pass 3 or 4 parameters to constructor. <?php class db_connection{ //To store the databse name private $_database = ""; //To store the connection values private $_mysqli_link; //Declaration of dynamic constructor public…
How to Connect a Database in MySQL Using PHP
This code will allow you to connect a Database in MySQL in PHP programming language. There are basically two ways you want to access your database. One is to your local server other one is online server. Method 1: Via local server This method allows you to connect to your local server <?php //Change your information according to your server $username = "your_username"; $password = "your_password"; $database =…