Ask your Question

Discover our new Professionals

Bhuwan
Bhuwan

Intern PHP Developer

Dehradun,  India
Mintu
Mintu

Faridabad,  India
Randip
Randip

eCommerce Web Developer

Deerfield Beach,  United States
UDAYAKUMAR
UDAYAKUMAR

PHP devoloper

Bangalore,  India
rakesh
rakesh

Software Developer

Delhi,  India

Write to us

Ask Question

Autoloading Classes

Autoloading Classes

 While writing object-oriented programming we have to include class files to call the method of the classes.

Sometimes we have to include a long list of needed includes (one for each class) at the beginning of each script.

Now, in PHP5 there is no longer necessary to includes classes. In PHP5 the spl_autoload_register function registers any number of autoloaders , enabling for classes and interfaces to be automatically loaded if they are not defined, PHP is given a last chance to load the class before throwing error.

 e.g :

<?php

 spl_autoload_register(function ($classname) {

    include  $classname . \'.php\';

});

 $object  = new Class1();

$object2 = new Class2();

 ?>

In the above example we do not need to include class1.php and class2.php .  spl_autoload_register() function will automatically load class1.php and class2.php .

... Read More

Need of object oriented programming (OOP)

Need of object oriented programming (OOP)

 

When we are going to work with classes and objects we always think why there is need of classes and object although without classes and objects our code works well. But after some work on classes and objects we think, yeah its better to work with classes and objects .And then we can understand that Object oriented Programming is better than procedural Programming.

Object oriented programming requires a different way of thinking about how can we construct our application.

Lets take a short example:

 

When we are going to build a house .We distribute the works needed to make a house we can divide the works in different part and deliver to different persons like plumber for water supply, electrician for electricity etc. The electrician doesn’t need to know that the work of plumber and vice versa.

In the same way in Object Oriented Programming we can divide our applications in different modules called classes .And one class is separate from other classes .It has its own functionality and features.

 

So what advantages we can get from Object Oriented Programming:

 

1: Reusability Of Code:  In object oriented programming one class can easily copied to another application if we want to use its functionality

       e.g.  When we work with hospital application and railway reservation application .In both application we need person class  so we have to write only one time the person class  and it can easily use in other application.

 

2: Easily Discover a bug: When we work with procedural programming it take a lot of time to discover a bug and resolve it .But in object   Oriented Programming   due to modularity of classes  we can easily discover the bug and we have to change in one class only and  this change make in all the application only by changing it one class only.

 

3: Object- Oriented Programming enables us to easily model our applications based on the real world which help us to easily identify the requirements, what code is to be written and how different classes interact with each other which have same properties and behaviors.

... Read More

CSS insert in database

CSS insert in database

How to insert CSS in phpmyadmin database and how to get CSS in the database

 

 

 

... Read More

PHP latest release 5.6.12

PHP  latest release 5.6.12

The PHP development team announces the immediate availability of  PHP 5.6.12 on 6th August 2015.
In this version the 12 security-related issues were fixed .
Issues of SOAP, GD, MCrypt, PCRE etc, has been fixed in this version
All PHP 5.6 users are encouraged to upgrade to this version.
We can download the latest version of PHP from PHP.net download page http://www.php.net/downloads.php and the changes logs are
mentioned on the site link http://www.php.net/ChangeLog-5.php#5.6.12.
 

... Read More

Rating Issue

Rating Issue

  Hi everyone, am trying to save and display the textbox color after select change in php and html. After selecting Selfrating1 ie "Good", the textbox T11 suppose to change to "Green" color. After submit button the textbox color supposed to be save in mysql and display on the form. The Selfrating1 can be save and display but the textbox color goes back to black and it doesn\'t save in the mysql.

Actually what suppose to happen is:
 
1.User select option Selfrating1
2.Once option has been selected, textbox T11 will change color based on select option
3.After submit button click, textbox T11 supposed to save color in mysql and display
Currently the problem is on No. 3 as the textbox T11 cannot be save in mysql and doesn\'t display the color change.
Please advise. Thanks.
 
 
 
 <?php
session_start(); 
$con = mysql_connect("localhost","user","");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("p",$con);
$Picid = $_GET[\'Picid\'];
$nwQty = "SELECT * FROM progress WHERE Picid = \'$Picid\'";
$solution = mysql_query($nwQty);
if(isset($_POST[\'submit\'])){
if (mysql_num_rows($solution) == 0){
$sql = "INSERT INTO progress(T11,Selfrating1,Picid) VALUES (\'" . $_POST["T11"] . "\',\'" . $_POST["Selfrating1"] . "\',\'" . $Picid . "\')"; 
$result = mysql_query($sql);
else {
$sql =("UPDATE progress SET T11=\'" . $_POST["T11"] . "\', Selfrating1=\'" . $_POST["Selfrating1"] . "\'
WHERE Picid=\'" . $Picid . "\'");
$result = mysql_query($sql);
echo(\'Record Updated\');
}
$result = mysql_query("SELECT * FROM progress WHERE Picid=\'" . $Picid . "\' ");
$row= mysql_fetch_array($result); 
}
?> 
 

 

... Read More

Please rotate your device

We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site