Category: php

PHP is a server-side scripting dialect composed essentially for web improvement yet in addition utilized as a universally useful programming dialect.

PHP takes after couple of guidelines and keeps up its style of coding. As there are numerous coders and engineers everywhere throughout the world, so each of them can take after various coding styles and norms yet this would have raised extraordinary disarray and trouble for a designer to comprehend another designers code. It would have been difficult to oversee and store the code for future reference. Here is the place the coding models become possibly the most important factor. This makes a code simple to peruse as well as makes the code simple to allude later on. This makes the code reasonable and clearer to decode, much the same as an outline. This additionally makes the code more formal and industry or programming focused. Underneath specified are couple of rules that one must follow keeping in mind the end goal to keep up the standard of PHP coding.

PHP labels : One must utilize the PHP standard labels(), as opposed to the shorthand labels() to delimit the PHP code.

Remarking : Use of standard C and C++ remarking style i.e., (//) – for single line and (/*/) – for multi-line, is exceptionally supported and utilization of Python or Perl style of remarking i.e., (#), is debilitated.

Line length and Indentation : It is a standard proposal to not surpass more than 75-85 characters for every line of code. One must not utilize tabs for space rather utilize 4 spaces as it is the standard indenting technique in the greater part of the programming dialects.

Organizing the control stream proclamations: The control stream or restrictive articulations must be composed in such a route in this way, to the point that it could be separated from work call explanations. While composing if, for, while, switch and other control stream proclamations there must be one space between the watchword and the opening bracket. Illustration: Output:

Positive

Capacity Calls : While composing a capacity call explanation, there must be no space between the capacity name and the opening paranthesis. Illustration: Output:

11

Naming Variables : Here are couple of traditions that one must follow keeping in mind the end goal to name the factors:

Utilization of lower case letters to name the factors.

Utilization of ‘_’ to isolate the words in a variable.

Static variable names might be begun with a letter ‘s’.

Worldwide variable names must begin a with letter ‘g’.

Utilization of capitalized letters to characterize worldwide constants with ‘_’ as a separator.

Piece allignment : Every square of code and wavy props must be alligned.

Short Functions : All capacities and strategies must confine themselves to a solitary page and should not be extensive.

Note: The above guidelines are given just to make the code effectively reasonable and to deal with the code effortlessly. There won’t be a particular blunder in the event of infringement of the standards said above. Be that as it may, it is very prescribed to take after the above tradition to enhance the general nature of code from a designer’s point of view.

This article is contributed by Chinmoy Lenka. On the off chance that you like GeeksforGeeks and might want to contribute, you can likewise compose an article utilizing contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article showing up on the GeeksforGeeks fundamental page and help different Geeks.

If it’s not too much trouble compose remarks in the event that you discover anything off base, or you need to share more data about the theme examined previously.

0

A quick introduction of .htaccess with examples

What is .htaccess? The .htaccess file is a configuration file that affects how a webserver responds to various requests. Why is it called .htaccess? (Hyper Text + Access) These files were first used to...

0

Codeigniter insert if not exist and update if not

  First you need to check whether the user or data is exits or not. then you can perform the update and insert operation. $this->db->where(‘user_id’,$id); $q = $this->db->get(‘profile’); if ( $q->num_rows() > 0 )...

CakePHP in a subdirectory using nginx 0

CakePHP in a subdirectory using nginx

CakePHP in a subdirectory using nginx cakephp subdirectory nginx I was facing many issues in setup cakephp3 in subfolder on nginx server. I was doing changes in new server config while we have to...

codility brackets opening and closing solution 0

codility brackets opening and closing solution

Codility brackets opening closing. codility brackets opening closing. codility you are given a string s consisting of n brackets opening problem solution. function isBalanced($str){ $count = 0; $ocount = 0; $ccount = 0; $length...

Push notification Android Php 0

Push notification Android Php

Hey, Today we learn how to send push notification for android in php. First create a class with following code   <?php class Pusher{ const GOOGLE_GCM_URL = ‘https://android.googleapis.com/gcm/send’; private $apiKey; private $proxy; private $output;...

Push notification IOS 0

Push notification IOS

Push notification IOS   <?php // authentication $host = “localhost”; $user = “user”; $pass = “pass”; $dbname = “DB”; // create connection with database $con = mysql_connect($host, $user, $pass); // check whether database connection...

Configure ejabberd xmpp on ubuntu server part-2 0

Configure ejabberd xmpp on ubuntu server part-2

configure ejabberd xmpp ubuntu server part 2 In First Tutorial we have configure ejabberd XMPP with default menisa database . now in this tutorial i will explain how to configure ejabberd with MySql ....

Configure ejabberd xmpp on ubuntu server Part-1 0

Configure ejabberd xmpp on ubuntu server Part-1

Configure ejabberd xmpp ubuntu server     After facing so many issues and investing so many hours I write below steps for configure ejabberd. In first tourial we learn how to configure ejabbere on...

export database table by php 0

export database table by php

export database table php Sometime there is need to export database table by php code. There is a very simple approach to do this.     /*******EDIT LINES 3-8*******/ $DB_Server = “localhost”; //MySQL Server...