Write a Java program to find GCD of two numbers using Recursion. Given two input integers, we have to write a code to find GCD of two numbers using recursion. For this program, I assume you are familiar with the concept of recursion. If you don’t know about recursion then check my previous post on recursion vs iteration.
What are PHP Magic Methods?
PHP Magic methods are a specialized method that is executed in response to a specific event. Each magic methods start with two underscores(__) and it is called automatically when a certain condition is met. It triggers custom behaviors defined by a programmer inside the class. Some of the magic methods are __construct(), __destruct(), __toString(), __get(), __set(), __call() etc.
In this tutorial, we are going to explore these magic methods.
PHP Magic Methods
What is an interface in PHP? An interface is an important concept in an object oriented programming.
In this tutorial, we’ll discuss following points.
1. What is an interface?
2. How to create an interface in PHP.
3. What’s the importance of using an interface in our PHP application?
Interface in PHP
What is an Interface in PHP?
An Interface defines a contract for what a class can do, without saying anything about how the class can do it. Through interfaces, we define what a class can do, the classes that implement interface define how it can do it.
To understand the concept of an interface let’s take an example of a caching system. There are different types of caching available such as File system, Memcache, Redis etc. First, we need to define what a cache can do (I mean different operations), how we do it? we can do it through an interface. A class (Such as Memcache, Redis etc) which implements cache interface will define how they will do it.
NOTE – An interface will not add any additional functionality in your code but it outlines a standard format to which your classes need to use.
Write a java program to find the first non-repeated character in a string.Given an input string, we have to write a java code to find the first non-repeated character in a string.
For example –
i) Input string – java
Output – j (j is the first non-repeating character in a string)
ii) Input string – web rewrite
Output – b (b is the first non-repeating character in a string)
PHP 7 Features Explained with Code Examples.
PHP 7 is the newest version of PHP released last year. PHP community has introduced a lot of new features in their latest version. In this tutorial, we are going to learn about new features added in PHP 7.
What’s a PHP composer? How to use PHP composer in your PHP Application? What are the benefits of using composer in your application?
PHP Composer is a dependency manager. It manages the dependency of PHP packages in your application. Using composer you can pull the required library and dependencies and manage them in one place. The concept of a composer is similar to npm in node.js and gem in Ruby.
Let’s first understand what is a dependency.
Abstract class vs interface in PHP. What’s the Difference between an abstract class and interface in PHP? It is one the most important oops concept asked in an interview.
In this tutorial, You are going to learn some important differences between an abstract class and interface.
How to create multiple database connections in Lumen.
Last week I was working on a project in which I need multiple Database connections. I need one separate database connection for reporting (Only for a read operation) and another for the rest of the work (Read & write both).
Write a program to check whether two strings are anagrams of each other.
What is an Anagram ?
Two strings are said to be anagrams of each other if it contains the same characters, only the order of characters in both the strings is different. In other words, both strings must contain the same exact letters in the same exact frequency.
How to debug SQL queries in Laravel & Lumen. During development of an application, there may be times when we need to write large and complex queries. Laravel provides an awesome query builder and ORM (Eloquent) to do this task effortlessly. But sometimes we would like to see the actual SQL being generated.