Ruby Course – Worldwideasy – 03

Ruby Programming lesson 3. Today we going to learn more about it. Today I will focus on Getting User Input, Hashes, Method and If Statement. Finally, Create a simple Calculator. It can provide extensive knowledge.

Getting User Input in Ruby Programming

Uses any computer language user input is how Ruby does it. But it happens here in a very different way. We are focusing on that step by step.

First, you need to install Platformio-ide-terminal on Atom text editor.

  1. Go Settings
  2. >> install
  3. Search “Platformio-ide-terminal”
  4. Install it
  5. Search “Ruby Ide” and install it

The code below explains it to you.

puts "Enter Name "
name = gets
puts ("hello" + name)

Run using CMD this code output is hello with your entered name. see below another example

puts "Enter Your Name: "
name = gets.chomp()
puts "Enter Your Age: "
age = gets.chomp()
puts ("hello" + name + "you are " +age)

Hashes in Ruby Programming

A hash function is any function that can be used to map data of arbitrary size to fixed-size values. The values ​​given by a hash function are called hash values, hash codes, digests, or simply hashes. Values ​​are used to index a fixed-size table called a hash table.

Hashes are used to shorten a word or line of words and make it very easy to code. The following example illustrates this for you.

New York >> NY
Sri Lanka >> SL
Hello World >> HW 

As mentioned above, those words are short but the output is long.

Method

Object-oriented programming is a method of action related to a message and an object. An object consists of data and behaviors; These have an interface that specifies how the object can be used by its various customers.

You have an understanding of the method Now let us see how to use this for ruby

def sayhi
  puts "Hello user"
end

puts 'top'
sayhi
puts 'bottom'

see below code output

Output

Another example

def sayhi (name)
  puts ("Hi " + name)
end

sayhi ("harry")

This Code Output is Hi harry

Create Calculator Using Ruby

We create a very good Calculator based on the knowledge we have learned about ruby ​​so far. Here you also have to learn about if

puts "Enter First Number : "
num1 = gets.chomp().to_f
puts "Enter Opartor : "
op = gets.chomp()
puts "Second Number : "
num2 = gets.chomp().to_f

if op == '+'
  puts (num1 + num2)
else if op == "-"
  puts (num1 - num2)
else if op == "*"
  puts (num1 * num2)
else if op == "/"
  puts (num1 / num2)
else
  puts "invalid Enter"
end

Here you can input two numbers as output and select an operator and perform some action

Thank you for all!

More Ruby ClickHere!

See you Next Ruby Lesson Soon!

Ruby Course – Worldwideasy – 02

Ruby programming lesson 2. Today we going to learn more about Ruby. In this tutorial, we will focus on variables, Strings, Numbers, and Operations. It can provide extensive knowledge.

Use Variable

Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.

launchschool.com

Now you know what is variable, let’s use it Ruby Programming

character_name = "jenny"
character_age = "23"
puts "my name is "+ character_name
puts "my age is "+ character_age

This Code output is My Name is jenny my age is 23. you can try this code in your pc.

Working with Strings Ruby Programming

Threads are traditionally alphabetical. Now you can see how it works. see the below table and get an idea about ruby strings.

Phone = "Apple Iphone"
CodeOutput
puts Phone.upcaseAPPLE IPHONE
puts Phone.downcaseApple iPhone
puts Phone.stripApple iPhone
puts Phone.length12
puts Phone.include?"Apple"true
puts Phone.include?"cake"false
puts Phone.[3,5]le Ip
puts "hp".upcase()HP

Work with Strings

Working With Numbers

Every computer language uses numbers in particular. This is because it allows you to easily control the data. let me show you how to work with numbers in Ruby.

SyntaxCode
puts -5.43215-5.43215
puts 5+914
puts 5/90
puts 2*36
puts 2**38
puts 10%31
puts 5-23

Operations & Math in Ruby Programming

In mathematics, we use different operations, i.e. maximum value, square root, fall. They are also used differently in programming. The following example will give you a broader understanding.

Operations
num = 30.67
CodeOutput
puts num.abs()30.67
puts num.round()30
puts num.ceil()31
puts num.floor()30

Operations

Math

it is a hard mathematics part but using ruby we can do it easily. see below table.

SyntaxOutput
puts Math.sqrt (2)1.4142135623730951
puts Math.log (2)0.6931471805599453

Math

Now you have developed some knowledge about Ruby. Try typing this code on your computer as well. Practice

Thank you for all!

More Ruby ClickHere!

See you Next Ruby Lesson Soon!

Ruby Course – Worldwideasy – 01

Ruby programing is a defined, high-level, general-purpose programming language. It was designed and developed by Yukihiro “Mats” Matsumoto of Japan in the mid-1990s. is dynamically typed and uses garbage collection.

Ruby programming is a high-level programming language. The implementation language here is c. This was created in 1995 by Yukihiro Matsumoto. The file extension here is .rb. Editors used for this are Atom, Komodo IDE, and RubyMine. This language is a language that can do all the work of web design & software development. Let us now learn about this step by step.

How to install Ruby in your pc!(Windows).

  1. First Download & Install Atom Editor.
  2. Open Atom.exe
  3. Find head bar >> Packages >> Settings View >> Install Package.
  4. Now search bar search “Atom-runner.
  5. And install this package close Atom.
  6. Download Ruby Pack.
  7. Install base install.
  8. Check installation
    1. open cmd
    2. type ruby -v
    3. you can see ruby version.

Ruby Frameworks

What is the framework? This is software. This helps to make the website easier. It has more options to easily develop any program. has web services, web resources, and web APIs. It helps us to develop a good website. But to work with Ruby Framework you need to have a basic knowledge of Ruby. See below its top 10 frames in 2020.

  1. Ruby on Rails
  2. Sinatra
  3. Padrino
  4. Hanami
  5. NYNY
  6. Scorched
  7. Hobbit
  8. Cuba
  9. Crepe
  10. Nancy

I recommend developing using Ruby on Rails and Sinatra is good. I put a link below you can go its site,

How to Make First Ruby File

Hello World

  • First Open Atom Editor.
  • This language is similar to Python and R. No blocks.
  • Ruby have 2 main text output method it is puts or print you can use both of them.
  • Special Ruby code line end not use semicolon ( ; ).
  • See below full code of hello world in Ruby,
print "Hello "
puts "World"
  • Save now (ctrl + s)
  • Run code (alt + r)
  • You can see below output Hello World.

Thank you for all!

More Ruby ClickHere!

See you Next Ruby Lesson Soon!

C# Course – Worldwideasy – 05

C# lesson 5. I will focus on 2D Arrays, Class, Object. Finally, Interface design. It can provide extensive knowledge.

2D Arrays in C#

A two-dimensional array has a type like an int [ ] [ ] or string [ ] [ ], with two pairs of square brackets. The element of a 2D array is arranged in rows and columns, and the new operator for the 2D array specifies both the number of rows and the number of columns.

You can get an Idea Using the Example Below about 2d arrays.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] cat =
            {
                {1,2},
                {4,6},
                {8,9}
            };
            Console.WriteLine(cat[0,1]);
            Console.ReadLine();
        }
    }
}

This code Answer is 2.

Object & Class in C#

Class is collection of objects and functions.

programming class

In computer programming, a function object is a construct that allows an object with the same syntax to be called or called a normal function. Active objects are often referred to as funksters.

Object in programming

He is a simple miner to the class. In object-oriented programming, we find a class. The use of this concept revolutionized the software development industry. This made it possible to create very fast software with a small amount of code. What makes it special is the ability to reuse the code. Let’s see how to use it for C #. The following example shows how to publish and execute a class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        class book{                    // Create Class
            public String title;
            public String Author; 
            public int pages;
        }
        static void Main(string[] args)
        {
            book book1 = new book();     // Call Class
            book1.title = "Harry Potter";
            book1.Author = "JK";
            book1.pages = 450;

            Console.WriteLine(book1.pages);
            Console.ReadLine();
        }
    }
}

You can see this code do create class and call class.

Now show you how to work class using method look below example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        public  Book (String name, int pages)
        {
            name = aname;
            pages = apages;
        }
        public bool hash()
        {
            if (pages > 200)
            {
                return true;
            }
            false{
                return false;
            }
        }
        static void Main(string[] args)
        {
            Book Book1 = new Book("magic", 280);
            Console.WriteLine(Book1.hash());
            Console.ReadLine();
        }
    }
}

This code output is True.

Work with interface in C#

Now over the php basic course. now let’s try to work with the interface. following this stape.

  • File –> New Project.
  • Select Windows Forms Application.
  • OK -> you can see empty form.
  • Now you can See Left side in toolbox.
  • Drag and Drop label.
  • Go Label properties go appearance. See Right (Clear field);
  • Drag and Drop Text Box.
  • Drag and Drop Button.
  • Double Click Button.
  • Type this code. label1.Text ="Hello" + textBox1.Text;

Now over the C# basic course. you go to this link and answer the question and get C# certificate. Get Certificate

Thank you for all!

More C# ClickHere!

See you Next Lesson Soon!

C# Course – Worldwideasy – 04

C# lesson 4. I will focus on Getting Control Statements (IF statement, Switch, loops). Finally, Create a simple Power Calculator. It can provide extensive knowledge.

A control statement is a statement that determines whether other statements are active. If a statement decides whether another statement should be executed, or one of the two statements to be executed. A loop determines the number of times another expression should be executed.

Control Statement mean

Basically have 3 control statements in php

  • IF
  • Switch
  • Loops

IF Statement in C#

If a statement is used to check the condition, it can be a condition or more. The special feature of it is that you can check any gap. The following example will make it clear to you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int mark = Convert.ToInt32(85);
            if (mark > 50)
            {
                Console.WriteLine("Pass");
            }
            else
            {
                Console.WriteLine("Fail");
            }
            Console.ReadLine();
        }
    }
}

This code output is given as Pass. Here, it checks if the value of the mark is greater than 50. It is represented as true pass and False as Fail.

else if

This is used to check several conditions at once. look following example will make it clear to you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int mark = Convert.ToInt32(67);
            if (mark > 75)
            {
                Console.WriteLine("A");
            }
            else if (mark > 65){
                Console.WriteLine("B");
            }
            else if (mark > 55)
            {
                Console.WriteLine("C");
            }
            else if (mark > 40)
            {
                Console.WriteLine("S");
            }
            else
            {
                Console.WriteLine("F");
            }
            Console.ReadLine();
        }
    }
}

This code output is B. You can see this code many times check conditions.

Switch

The switch expression is used to check several non-gap conditions. This works very fast and gets the idea below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            int day = 2;
            switch (day)
            {
                case 1:
                    Console.WriteLine("Sunday");
                    break;

                case 2:
                    Console.WriteLine("Monday");
                    break;

                default:
                    Console.WriteLine("Wrong");
                    break;

            }

            Console.ReadLine();
        }
    }
}

This Code output is Monday. A Break statement is used for stop the function.

Loops

Loops have main 3 loops in c#

  • For loop
  • While loop
  • Do While loop

Now I show all loops using Code. See Below all code output is the same. output is : 10,9,8,7,6,5,4,3,2,1.

For loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
        for (int i=10; i >= 1; i--)
            {
                Console.WriteLine(i);
            }
            Console.ReadLine();
       
        }
    }
}

While Loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 10;
            while (i >= 1)
            {
                Console.WriteLine(i);
                i--;
            }
            Console.ReadLine();
       
        }
    }
}

Do While Loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 10;
            do
            {
                Console.WriteLine(i);
                i--;
            } while (i >= 1);
            Console.ReadLine();
       
        }
    }
}

Now you have very good knowledge about C #. Practice this over and over again. Let us now see how to make a power calculator from what we have learned so far.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("****POWER CALCULATOR****");
            Console.WriteLine("Enter Base Number : ");
            int x = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Power Number : ");
            int y = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Power is: "+getpow(x,y));
            Console.ReadLine();
       
        }
        static int getpow(int basenum, int pow)
        {
            int result = 1;
for(int i = 0; i < pow; i++)
            {
                result = result * basenum;
            }
            return result;
        }
    }
}

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

C# Course – Worldwideasy – 03

Today we expect to Get User Input, Arrays, Methods, Return Types, and finally make a Simple Calculator. this all is we are doing C# console application. it uses forget good basic knowledge for C#.

C# User Input

Here we take user input and inquire how to perform a certain function. It can make more creative creations. You can get an understanding of it in the following way. See Below Example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Your Name : ");
            String name = Console.ReadLine();
            Console.WriteLine("Your Name is " + name);
            Console.ReadLine();
        }
    }
}

This Code output is Program ask your name you can type it. after the program give output your name is “You entered the name”.

Arrays

The array is a specials type of programming language. now we can see how to work array in C # . let’s see below code example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num = { 1, 2, 3, 4, 5, 6 };
            Console.WriteLine(num[3]);
            Console.ReadLine();
        }
    }
}

This code output is 4. Array using the same data type list add to the program.

Method Using C#

Here we take user input and inquire how to perform a certain function. It can make more creative creations. You can get an understanding of it in the following way.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            sayhi();
            Console.WriteLine("How you");
            sayhi();
            Console.ReadLine();
        }
        static void sayhi()
        {
            Console.WriteLine("Hello World");
        }
    }
}

This code output is Hello World How You Hello World. You can try this code on your Computer.

Return Type

What is done here is to show the output that we need to take into another function in a process that is done in a method. The following example code will make it clear to you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(cube(5));
            Console.ReadLine();
        }
        static int cube (int num)
        {
            int cube = num * num * num;
            return cube;
        }
       }
}

This code output is 125. you can see cube is a function its return type is a cube (output). main function call cube function finally get an answer.

Create Calculator using C# Console

Now we try to Create Calculator using method, input, and others. see below code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Number one : ");
            String num01 = Console.ReadLine();
            Console.WriteLine("Enter Number two : ");
            String num02 = Console.ReadLine();
            float num1 = float.Parse(num01);
            float num2 = float.Parse(num02); //convert string to float
            Console.WriteLine("Answers is: ");
            Console.WriteLine("Add = "+add(num1,num2));
            Console.WriteLine("Cut = "+cut(num1, num2));
            Console.WriteLine("Multification = "+mul(num1, num2));
            Console.WriteLine("Sub = "+sub(num1, num2));
            Console.ReadLine();

        }
        static float add(float num1,float num2)
        {
            float total = num1 + num2;
            return total;
        }//add

        static float cut(float num1,float num2)
        {
            float cut = num1 - num2;
            return cut;
        }//cut
        static float mul(float num1, float num2)
        {
            float mul = num1 * num2;
            return mul;
        }//mul
        static float sub(float num1, float num2)
        {
            float sub = num1 / num2;
            return sub;
        }//sub

       }
}

You can see below output this code doing how to convert string to float.

Now you have good knowledge of this programming language of today’s lesson. practice this code and develop your knowledge.

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

C# Course – Worldwideasy – 02

Today we expect Variables, Data Types, Strings, and working with Numbers. this all is we are doing C# console application. its uses forget good basic knowledge for C#.

C# Variables

Variable is a symbol that acts as a holder for various expressions or sizes and is often used to represent an arbitrary element of a set.

You now have a broader understanding. about what a variable is. So let us explain by c #. See the below example.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String chaName = "Harry";
int age = 30;

Console.WriteLine("my name is " + chaName);
Console.WriteLine("I am " + age);
Console.WriteLine("I like " + chaName);
Console.WriteLine("good for " + age);
Console.ReadLine();

}
}
}

This code Output is My Name is Harry. I am 30. I like Harry. good for 30. You can try this code on your pc.

C# Data Types

This is special it uses to make variables. c# is a case-sensitive language. We must first say that the type of data that the computer recognizes. There are a limited number of data types that we can identify.

Data TypeSyntax
StringString name = "Hello";
Charchar grade = 'A';
intint age = 30;
floatfloat gpa = 3.2f;
doubledouble gpa = 2.35686;
boolisMale = true;

Data Types

Strings

Strings do a lot of work. We can do it very beautifully and easily. This is very useful for tasks like changing a name. Get an understanding from the table below.

SyntaxOutput
Console.WriteLine ("hello world");hello world
Console.WriteLine ("hello \n world");hello
world
Console.WriteLine ("hello\"world");hello”world
String Ad = "hello" + "boy";
Console.WriteLine (Ad);
hello boy
String Ad = "Apple";
Console.WriteLine(Ad.Length);
5
Console.WriteLine(Ad.ToUpper());APPLE
Console.WriteLine(Ad.ToLower);apple
Console.WriteLine(Ad.Contains(“hp”);false
Console.WriteLine(Ad.Contains(“Apple”);true
Console.WriteLine(Ad.[3]);L
Console.WriteLine(Ad.Indexof(‘l’));3
Console.WriteLine(Ad.Substring(2));ple

Use for String

Work With Numbers

This allows us to see how the code makes various changes to the numbers. See the table below. Get ideas from it.

SyntaxOutput
Console.WriteLine(5+7);12
Console.WriteLine(Math.Abs (-40));40
Console.WriteLine(Math.Pow (4,2));16
Console.WriteLine(Math.Sqrt (144));12
Console.WriteLine(Math.Max (10,20));20
Console.WriteLine(Math.Min (10,20));10
Console.WriteLine(Math.Round(4.2));4
Console.WriteLine(Math.Sin(55));-0.99975517335862

Work with Numbers

More about Work with Numbers. example works.

SyntaxOutput
Console.WriteLine(8+6);14
Console.WriteLine(152-56);96
Console.WriteLine(80/5);16
Console.WriteLine(8%3);2
Console.WriteLine(8*3);24
Console.WriteLine((8+9)*(8+2));170

Operations

Now you have the basic knowledge of c #. You can get a better understanding by trying the code again.

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

C# Course – Worldwideasy – 01

C # is a multi-purpose programming language with general-purpose, including static typing, robust typing, vocabulary scope, essential, expression, functional, generative, object-oriented, and component-oriented programming discipline.

Today we expect basic knowledge from installing c # on a computer to coding and outputting.

C #  created by Microsoft Corporation. The platform here is a common language infrastructure. It is best to use Microsoft Visual Studio as the editor. Also, software such as Resharper can be used. The main framework of C # is the .NET Framework, which makes it easy to create user interfaces. C # is a language commonly used to build Windows applications and games.

C# does not need to be specifically entered into the computer. It is obtained automatically installing visual studio..

Start C# Coding

  1. First you want Download And Install Visual Studio(Windows operating system).
  2. Open Visual Studio.
  3. Go file and New project.
  4. Select Visual C# to Console Application and ok.
  5. After you can see Default code in below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Code Here 
}
}
}

The code above must be present.

First Code in C#

Let’s see how to write code to print hello world.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
Console.ReadLine(); 
}
}
}

Type the code above in the toolbar. Click the Start button and you will get the output on a black screen as shown below.

hee
Output

Now you can type the code and run it. Edit the code above and try again. Next, we are going to show any shape using only the code called writeline();.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("      **");
Console.WriteLine("      /|");
Console.WriteLine("     / |");
Console.WriteLine("    /  |");
Console.WriteLine("   /   |");
Console.WriteLine("  /    |");
Console.WriteLine(" /     |");
Console.WriteLine("|      |");
Console.WriteLine("|      |");
Console.WriteLine("|      |");
Console.WriteLine("|______|");
Console.ReadLine();
}
}
}

Thank you for all!

More C# ClickHere!

See you Next C# Lesson Soon!

Php Course – Worldwideasy – 05

php lesson 5. I will focus on Class, Construct, Object, getter, setters, and Inheritance. Finally, we can complete today’s php basic course.

Php Class

Class is collection of objects and functions.

This is simple mining for the class. We find a class in object-oriented programming. The use of this concept revolutionized the software development industry. This made it possible to create very fast software with a small amount of code. The specialty here is the ability to reuse code. Let’s see how to use it for php. The following example shows how to declare and execute a class.

<?php
class Book {
var $name;
var $author;
var $price;               //class assing
}
$book1 = new book;
$book1 = name = "Harry Potter";
$book1 = price = "1700";          //make objects
$book1 = author = "JK";

echo $book1 -> name;
echo $book1 -> price;
?>

This code output is Harry Potter 1700.

Constructor

In class-based object-oriented programming, a constructor is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables

You can get a good idea using the following example about php constructor.

<?php
class Book{
var $name;
var $price;
var $author;
function__construct(){
echo"this is book<br>";
}
}
$book1 = new Book;
$book2 = new Book;
?>

This code output is is book two-time print.

Object and Functions

In computer programming, a function object is a construct that allows an object with the same syntax to be called or called a normal function. Active objects are often referred to as funksters.

This is the mining of the object and functions. now we can try to add it php. look below example.

<?php
class student {
var $name;
var $stream;
var $gpa;
 function__construct ($name,$stream,$gpa){
$this->name = $name;
$this->stream = $stream;
$this->gpa = $gpa;
}
function hasHonors(){
if ($this->gpa>2.5){
return "true";
}
else{
return "false";
}
}
}
$student1 = new student ("jane","Maths","3.2");
$student2 = new student ("mick","Biology","2.4");

echo $student1 -> hasHonors();
echo $student2 -> hasHonors();
?>

This code answer is truly false.

Getters and Setters

get create a function function getRating(){}

using if statement function setRating($rating)

Private can not be changed. The public can be change.

Inheritance

Object-oriented programming, inheritance, is the mechanism by which an object or class retains a similar function based on another object or class. Also defined as taking new classes from existing classes, such as the superclass or the basic class, and converting them into a hierarchy of classes.

see below you can get an idea for inheritance.

<?php
class chef{
function makechicken(){
echo "make chicken";
}
function make salad(){
echo "make salad";
}
function make bbq(){
echo "make bbq";
}
}
$italianchef = new italianchef;
echo $italiancheff->makechicken();
echo $italiancheff->makebbq();
?>

output is made chicken and makes bbq.

Now over the php basic course. you go to this link and answer the question and get PHP certificate. Get Certificate

Thank you for all!

More php ClickHere!

See you Next Lesson Soon!

Php Course – Worldwideasy – 04

php lesson 4. I will focus on Getting Control Statements (IF statement, Switch, loops). Finally, Create a simple Grading Calculator. It can provide extensive knowledge.

Control Statements

A control statement is a statement that determines whether other statements are active. If a statement decides whether another statement should be executed, or one of the two statements to be executed. A loop determines the number of times another expression should be executed.

Basically have 3 control statement

  • IF
  • Switch
  • Loops

IF Statement in php

If a statement is used to check the condition, it can be a condition or more. The special feature of it is that you can check any gap. The following example will make it clear to you.

<?php
$name = "apple";
if ($name="apple"){
echo "true";
}
else{
echo "false";
}
?>

This Code output is true.

Switch

The switch expression is used to check several non-gap conditions. This works very fast and gets the idea below

<?php
$ grade = $_POST["grade"];
switch ($grade) {
	case 'A':
		echo "A";
		break;
		case 'B':
		echo "B";
		break;
		case 'C':
		echo "C";
		break;
		case 'S':
		echo "S";
		break;
		default:
		# code...
		break;
}

Loops

Loops have main 3 loops in php

  • For loop
  • While loop
  • Do While loop
  • Foreach Loop

Now I show the First 3 loops using Code. See Below all code output is the same. output is : 1,2,3,4,5,6,7,8,9,10

For Loop

this is a simple and easy loop in any programming language.

<?php
for ($int = 0; $int <= 10; $int++) {
  echo "$int <br>";
}
?>

While Loop

<?php
$int = 1;

while($int <= 10) {
  echo "$int <br>";
  $int++;
}
?>

Do while Loop

<?php
$int = 1;

do {
  echo "$int <br>";
  $int++;
} while ($int <= 10);
?>

Foreach Loop

This is a special loop for php. This is commonly used for arrays. see below example

<?php
$laptops = array("Dell", "Apple", "Hp", "Azus");

foreach ($laptops as $value) {
  echo "$value <br>";
}
?>

Include

you can see below example it do include HTML and php file.

<?php
include "header.html"
include "index.php"
?>

Simple Grading Calculator

See the example below and give it a try. This is a simple hierarchical calculator code. It has an HTML code that you can try on your computer. This calculator is made using what we have learned so far. So you can get a very good experience by practicing this.

<!DOCTYPE html>
<html>
<head>
	<title>Grading Calculator</title>
</head>
<body>
	<h2>Grading Calculator</h2><br>
    <form action="site.php" method="POST">
    	Marcks : <input type="number" name="num">
    	<input type="submit">
    	<br>
    	Grade is : 
    	<!--php code-->
    	<?php
    	$num = $_POST["num"];
    	if($num>=75){
    		echo "A";
    	}elseif ($num>=65) {
    		echo "B";
    	}elseif ($num>=65) {
    		echo "C";
    	}elseif ($num>=65) {
    		echo "S";
    	}else{
    		echo "F";
    	}
    	?>
    	
    </form>


</body>
</html>

Save this file. filename is site.php.

Thank you for all! do you have any questions Click here!

More php ClickHere!

See you Next Lesson Soon!