Error Handling in PHP

php-training-in-gurgaon
Error handling is the process of catching errors from the program and then taking appropriate action. Before proceeding for error handling you should get to know how many types of errors occurred in PHP. Notices: These are non-critical errors that occurred while executing a script - for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behavior. Warnings: These are more serious errors - for example, attempting to use a file (using include() method) which does not exist. By default, these errors are displayed to the user, but they do not result in script termination. Fatal Errors: These are critical errors - for example, creating an…
Read More

PHP – Strings Functions

php-training-in-gurgaon
String functions are the most important functions frequently used in PHP. String is the sequence of characters, like "Let’s learn String functions”. There is no installation required to use string function. Example <?php $name = "Hirdesh Bhardwaj"; print($name); ?> String Concatenation Operator To concatenate two string variables together, we use the dot (.) operator − <?php $txt1="Hello Readers"; $txt2="8756"; echo $txt1 . " " . $txt2; ?> Using the strlen() function The strlen() function is used to get the length of a string. <?php $txt=”Webs Jyoti”; echo strlen($txt); ?> This will produce the following result – 10 (including space) Using the strpos() function The strpos() function is used to search for a text or character within a string. If the value is found then this will return the position of…
Read More

OOPs Concepts – PHP

php-training-in-gurgaon
OOP is intimidating to a lot of developers because it introduces new syntax and, at a glance, appears to be far more complex than simple procedural, or inline, code. However, upon closer inspection, OOP is actually a very straightforward and ultimately simpler approach to programming. Before we go in details, let’s define important terms related to Object Oriented Programming. Class− Simply Class is a collection of member variables and its functions. Object−You define a class once and then make many objects that belong to it. Objects have state behavior and identity. Member functions and Variables− these are the functions and variables defined inside a class and are used to access object data. Inheritance– Simply creating a new class from the existing class. When a class is defined by inheriting existing…
Read More

Sending email – Mail Function in PHP

php-training-in-gurgaon
Almost in every web application sending automated email by system is the common requirement. So, it’s very common and important part that must be known by developer. The simple example, when a visitor to your website fills out a enquiry form. mail function return a boolen value, return true if email sent successfully, false otherwise  Syntax: mail ($to , $subject , $message, $additional_headers); $to: This is the first parameter of mail function hold the email address of receiver, the address to which email has to be sent. $subject: Every email should have subject. This parameter cannot contain any newline characters. $message: This is the actual body or content of email to send.  Please note that every line should be break by \n and every line should not exceed the limit…
Read More

Require () and Include () function in PHP

php-training-in-gurgaon
The Include() and require() statements are used to insert codes written in other files, in the flow of  execution. The main of using include and require functions to integrate one page code or content into another page. You can maintain usually some repeated functionality in the form of PHP file and finally you can call it wherever you want. See, the following example demonstrates how to integrate a menu content in other pages of PHP. There is a page in menu.php and it can be included in some other pages of the website. Menu.php <a href=”index.php”>Home</a> <a href=”services.php”>Services</a> <a href=”about.php”>About Us</a> <a href=”contact.php”>Contact Us</a> The following page index.php uses above menu.php content. See the below code how it follows <head> <title>My Web page</title> </head> <body> <?php include  “menu.php “; ?> </body> Difference between Include…
Read More

Introduction to Ajax

php-training-in-gurgaon
Ajax (Asynchronous Java script And XML)  Introduction In Jesse Garrett’s original article that coined the term, it was AJAX. The “X” in AJAX really stands for XML HTTP Request though, and not XML. Jesse later conceded that Ajax should be a word and not an acronym and updated his article to reflect his change in heart. So “Ajax” is the correct casing. As its name implies, Ajax relies primarily on two technologies to work: JavaScript and the XML HTTP Request. Standardization of the browser DOM (Document Object Model) and DHTML also play an important part in Ajax’s success, but for the purposes of our discussion we won’t examine these technologies in depth. How Ajax Works At the heart of Ajax is the ability to communicate with a Web server asynchronously without taking away the…
Read More