Saturday 24 March 2018

PHP Functions and Classes

PHP Functions and Classes

PHP is a recursive acronym for "PHP: Hypertext Preprocessor". It is a server side scripting language which is embedded in HTML. With the help of this many e-commerce sites are built and it manages dynamic content, databases, session tracking etc. It can be combined with number of famous databases, compose MySQL, PostgreSQL, Oracle,Sybase, Informix, and Microsoft SQL Server at PHP Training in chandigarh.

Some of the important functions, classes and features are:

Every programmer should have a basic understanding of PHP functions, classes and methods. We have gathered a list of important functions, classes and features below that every coder should know.

PHP Training in Chandigarh

1. PDO Class


PDO (PHP Data Object) are used for connecting to MySQL databases. It provides an abstraction layer for a set of database drivers such as MySQL, PostgreSQL and MS SQL.

This means that whatsoever database you are using, if PDO supports it, one can use the same functions to perform the same actions on the database. This generate the code more portable web application to be used in collection of databases with no increased development time.It provides functions such as creating transactions, creating prepared statements and allowing the escape of the variables if required.It can also help in secure web applications from SQL injection violation.

2. json_encode & json_decode


There are two very effective functions that allows to parse JSON (JavaScript Object Notation) strings. JSON is a text-based standard that is mainly used to send and receive data with a simple structure that was designed to be easily read, both by a computer and by a human.
PHP provides two functions that can manipulate data both to and from JSON.Learn advance techniques about JSON at PHP Training in Chandigarh.  
Json_encode is used by setting the first argument as your data. It can be a simple string or a multidimensional array, PHP will try to return a string of the data that has been converted to a JSON formatted string. It will be then used to output on an API or included in any HTML template to be read by the JavaScript code on the front end.
json_decode is the opposite of json_encode. The function will take the JSON string as the first argument and tries to parse the string into a PHP variable. Second argument is arbitrary which can navitiate the string to an object or an related array. By parsing ‘true’ as the second argument array will be returned.

3. DateTime Class


It allows to manage time and dates in a more object-ordinated way. By using DateInterval and DateTimeZone classes, adding or subtracting time period on a date or changing the current time zone can be done.It can be used to provide additional functionality which will make the code cleaner and easier to read. It stock entire the moment as a 64-bit integer, which offers a work for the 32-bit 2038 virus where the dates will cease to increase it any further.

4. Exceptions


PHP5 supports the implementation of exceptions. Exceptions are used to 'throw' errors that can be caught at any point by bubbling up through your code stack.Exception can be created easily using the throw keyword followed by an Exception object. Catching exceptions is done by wrapping the code in try block. Catch block needs to be created to 'catch' any exception that the code in the try block throws. PHP interpreter will try and parse everything in the block as usual. If no exception is thrown, interpreter will remain down the script ignoring anything in the catch block. However, if an exception is thrown, the code in block is ignored and will execute the catch block.
Exceptions can be extended as they are just classes. By extending to the standard Exception class one can give extra functionality to the exception.It allows multiple catch blocks that can refer to each exception class by utilizing type hinting.

5. Namespaces


With the use of namespace keyword followed by the namespace name at the top of a PHP file, it puts all the code below the reflective namespace that cannot be accessed by any other namespaces unless explicitly instructed to. With the use of namespaces, well-structured and readable code can be created that's easier to read and manage

6. glob


This activity offers an simple one-line clarification for generating an array of path names using a pattern you provide. Searching for a particular file type such as an image, then using glob could be a good solution to your problem.

7. Usort


It confess the developer to set an array based on a analyse activity that's configurable by the developer. It creates more complex sorting algorithms that are not possible with standard core array sort functions. One great example for usort is to sort a simple multi-dimensional array. For example, there is an array of students that consists of an associative array of name and age. With the use of usort function along with a callback/closure function, we can pick the age and sort by ascending or descending order.

8. Hashing API


The hashing API offers an easy-to-use layer on head of bcrypt to generate protected hashes that are a lot harder to solve by hackers. It provides a native password hashing API that safely handles both hashing and verifying passwords in a secure manner. There are excessive opportunities are feasible in PHP, but every programmer wish to embrace the base features mentioned in this article in order to become a PHP expert. By knowing these features you will be in position to pass any hurdles while coding in PHP. Without knowledge of these, it would be difficult to understand different frameworks.

CBitss Technologies is the best place for PHP those who want to learn more about functions go for PHP Training in Chandigarh .


Thursday 22 March 2018

Introduction of PHP

Introduction of PHP

PHP  Training in Chandigarh is the best option for the freshers like the students or the people which are a noob to the corporate world. The hypertext preprocessor is widely known as PHP .  It is most commonly used scripting language. Php scripts are executed on the server and the result is returned to the browser as a plain HTML. Moreover it is free to download and use.PHP use several cms( content management system )like Wordpress,Joomla,cake Php,Drupal etc...

 What actually Php files are?

Php files are usually not only consists of Php codes.
There are other files used in PHP  like JavaScript, HTML and CSS or other Texts.
These Php files are then saved by the .php extension.
Php can create dynamic page content and can be run on various platforms like
Windows
Linux
Mac OS X
Unix etc.

Php can create, Open, read, write and delete files on the server. Php is compatible with almost all the servers like IIS, Apache, etc.
Php can send and receive cookies and can collect form data. It can also encrypt
data. 
 

What are Php functions?

Php consists of nearly 1000 built-in functions, other than that we can create our own functions. There are various user defined functions.Before we talk about user defined functions, the first thing to know is:

what actually a function is?

“A function is usually a block of statement that can be used repeatedly in a program”.
A function will not execute immediately while the loading of the page.
A call to a function helps in executing a Function.
 How can we use User Defined functions in Php?
A function name should starts with a Letter or an Underscore.
Function names are not Case-Sensitive.

SYNTAX:

      Function functionname(){
Code to be executed;
}

Php Function Arguments :   

An argument is just like a variable. The information is passed to functions with the help of an Argument. Arguments are specified under the function name inside the Parentheses. The user can add as many arguments of their choice by separating them with the comma.
The following example has a function with one argument($fname). When the function Family Name() is called, we can also pass along a name( eg. jane), and the name is used inside the function which outputs several different First names but the same Last name.
<?php
Function familyname($fname){
      echo”$fname Refsnes.<br>”;
}
FamilyName(“Jane”);
FamilyName(“Chris”);
FamilyName(“Tony”);
FamilyName(“Martha”)
FamilyName(“rey”)
?>
Php default Argument Value
The following program is about the usage of Default parameter. If we call the function SetGrades() without arguments it takes the default value as an argument.

<?Php
Function SetGrades($minGrades = F){
        echo”the Grade is  :  $minGrade <br>”;
}
setGrade(A);
setGrade();                //will use the default value F
setGrade(B);
setGrade(C);
?>
 If you want to learn more about this so please visit : PHP Training in Chandigarh




 

Thursday 15 March 2018

PHP Functions

 PHP Functions

 

PHP functions are same to other programming languages .  A function is a quantity of code which proceeds one more input in the style of parameter and does any processing and returns a value . You already have seen many functions like fopen() and fread() etc . They are built-in functions but PHP gives you option to create your own functions as well.Now we discuss the types of functions with the PHP Training in Chandigarh . There are two parts which should be clear to you −
Creating a PHP Function
Calling a PHP Function
In fact you comparatively demand to build your particular PHP function because there are
already more than 1000 of built-in library functions created for different area and you just need to call them according to your requirement.

PHP User-Defined Functions :

In addition to the built-in functions, PHP also confess you to represent your particular functions . It is a way to create reusable code packages that perform specific tasks and can be kept and maintained separately from main program . Here are some advantages of using functions :
Functions break the repeat of code within a program — Function confess you to select commonly used block of code into a single component . Now you can perform the same task by calling this function wherever you want within your script without having to copy and paste the same block of code again and again.
Functions compose the code much easy to manage— Since a function organize once can be used many times, so any changes made inside a function automatically implemented at all the places without touching the several files.
Functions makes it easier to eliminate the errors — When the program is subdivided into functions, if any error occur you know exactly what function causing the error and where to find it. Therefore, fixing errors becomes much easier.
Functions can be translate into different application — Because a function is distract from the pause of the script, it's easy to reuse the same function in other applications just by including the php file containing those functions

Advantages of PHP Functions :

Code Reusability : PHP functions are defined only once and can be invoked many times, like in other programming languages .
Less Code : It saves a lot of code because you don't need to write the logic many times. By the use of function, you can write the logic only once and reuse it .
Easy to understand : PHP functions separate the programming logic . So it is simple to sympathize the movement of the application because each logic is split in the style of functions .
Functions with Parameters :
You can specify parameters when you define your function to accept input values at run time . The parameters task like plausibility variables within a function; they're replaced at run time by the values (known as argument) provided to the function at the time of invocation .
If you want to learn more about PHP Functions  so please join PHP Training in Chandigarh at Sector 34A.