Method Overloading in PHP

Alok Prasad
Updated on 31-Dec-2019 08:29:38

11K+ Views

Method Overloading is a concept of Object Oriented Programming which helps in building the composite application in an easy way. Function overloading or method overloading is a feature that permits making creating several methods with a similar name that works differently from one another in the type of the input parameters it accepts as arguments.The above concept is fine for other programming languages and it is called static polymorphic i.e method overloading.ExampleLet's understand through an example.Output:ErrorExplanation:This will generate an error since php will say you have declared this method twice.But Other programming languages says , doTask($var1) and doTask($var1, $var2) are ... Read More

Difference Between Abstraction and Encapsulation in PHP

Alok Prasad
Updated on 31-Dec-2019 08:20:07

1K+ Views

PHP5 added the object-oriented programming approach with the previous version, which is used for making code reusable in real time php application.Some of the concepts of object-oriented models are: class, object, encapsulation, polymorphism, abstract and final classes, and methods, interfaces and inheritance, etc...Here we discuss the basic differences between abstraction and encapsulation.Encapsulation:Encapsulation is an approach that joins data members(variables) and implementation details into a single unit called the class that implies class is formed with variables and methods present inside it.Encapsulation is a protection mechanism for data members present inside the class i.e data members are not accessible by end ... Read More

Remove Property Using jQuery with Examples

AmitDiwan
Updated on 31-Dec-2019 08:18:43

206 Views

The removeProp() method in jQuery is used to remove a property set by the prop() method.SyntaxThe syntax is as follows −$(selector).removeProp(property)Above, the parameter property is the name of the property to remove.ExampleLet us now see an example to implement the jQuery removeProp() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          var $val = $("div");          $val.prop("font-size", "1.6em");          $val.append("Property value = " + $val.prop("font-size"));          $val.removeProp("font-size");          $val.append("Property removed successfully...");       });    }); Adding ... Read More

Static and Instance Method in PHP

Alok Prasad
Updated on 31-Dec-2019 08:18:24

738 Views

In PHP, instance methods are the preferable practice over static methods. In any case, it isn't to say that static methods are not helpful, they have a distinct and unique purpose. Here we discuss a comparison between static and instance methods in PHP.Here Note that instance method is always connected to the object of the class while on the other hand static methods always connected with the class.First talk about static method. The static method in PHP is the same as other Object Oriented Programming Languages. Important cases for using the static method in PHP.The static method required to be ... Read More

Comparison of Floating Point Values in PHP

Alok Prasad
Updated on 31-Dec-2019 08:15:59

922 Views

In PHP, testing floating point values for equality is problematic, because PHP is failing when checking if one floating point number is equal to another. Despite the fact floating point numbers seems to have the same value do not need to actually be identical. So in this article will demonstrate the problem we are facing in comparison of Floating-Point Numbers and different procedures to avoid this problem.ExampleLet's test this with a simple example:output:a and b are not same.Explanation:In this code, the else condition is executed instead of the if condition, even though $a and $b are the same. It is ... Read More

jQuery Data with Examples

AmitDiwan
Updated on 31-Dec-2019 08:15:54

639 Views

The data() method in jQuery is used to attach data to or gets data from selected elements.SyntaxThe syntax is as follows −$(selector).data(name) $(selector).data(name, value)Above, the name is the name of data to retrieve for the 1st syntax.For the 2nd syntax, the name is the name of data to set, whereas value is the value of data to set.ExampleLet us now see an example to implement the jQuery data() method − Live Demo    $(document).ready(function(){       $(".button1").click(function(){          $("div").data("student", "Jack Sparrow");          alert("Student Name = " +$("div").data("student"));       }); ... Read More

Set Multiple Values for Custom Columns in MySQL

AmitDiwan
Updated on 31-Dec-2019 08:14:56

539 Views

For this, you can use UNION ALL. Let us first create a table −mysql> create table DemoTable1987    (    UserValue int    ); Query OK, 0 rows affected (2.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1987 values(4); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1987 values(5); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1987 values(6); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1987 values(7); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select * from DemoTable1987;This ... Read More

Display Specified Values Inside IN Clause with MySQL

AmitDiwan
Updated on 31-Dec-2019 08:13:56

122 Views

For this, you can use IN() along with ORDER BY clause. Let us first create a table −mysql> create table DemoTable1986    (    Number int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1986 values(50); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(60); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(100); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(200); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1986 values(350); Query OK, 1 row ... Read More

jQuery Index with Examples

AmitDiwan
Updated on 31-Dec-2019 08:13:05

279 Views

The index() method in jQuery is used to return the index position of specified elements relative to other specified elements.SyntaxThe syntax is as follows −$(selector).index()ExampleLet us now see an example to implement the jQuery index() method − Live Demo    $(document).ready(function(){       $("li").click(function(){          document.getElementById("demo").innerHTML = $(this).index();       });    }); Devices TV Laptop Headphone Earphone SSD Index = OutputThis will produce the following output −Now, to get the index of any of the list items, just click on it as shown below. We clicked “Headphone” here −

Convert Dates Like Jan 2017 and May 2018 to Complete Date in MySQL

AmitDiwan
Updated on 31-Dec-2019 08:11:30

206 Views

For this, use STR_TO_DATE() along with DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1985    (    DueDate varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1985 values('Jan 2017'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1985 values('May 2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1985 values('Aug 2015'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> select * from DemoTable1985;This will produce the following output −+----------+ | DueDate  | ... Read More

Advertisements