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!

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!

Php Course – Worldwideasy – 02

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

Use HTML For PHP

You can see below the HTML tag used in your php file.

<?php
echo "<h1>Micke</h1>";
echo "<hr>";
echo "<h1>"Jhone</h1>";
?>

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 php.

<?php
$charname ="Jhone";
$charage = '18';
echo "my name is" $charname;
echo "my age " $charage;
?>

Working with Strings

the string is traditionally a sequence of characters. now you can see how to work it. Look at Example.

<?php
$pharase = "Hello World";
CodeOutput
echo strtoupper ($pharase);HELLO WORLD
echo strtolower ($pharase);hello world
echo strlen ($pharase);10
echo pharase[1];e
echo str_replace("Hello","Hay",$pharase);Hay World
echo substr ($pharase,6);ld
echo substr ($pharase,4,7);owor

Syntax

Working With Numbers

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

<?php
echo 5;    //5
echo 5 + 9;   //14
?>
<?php
$num = 10;
$num ++;
echo $num;  //11

Operations

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.

NameSyntaxOutput
Powerecho pow(2,4);16
Square rootecho sqrt(144);12
Max Numberecho max(10,20,30);30
Min Numberecho min (10,20,30);10
Roundecho round (3.2);3
NOTecho abs(-100);100
Max Roundecho ceil(3.2);4
Min Roundecho floor(3.8);3

Operations

Special Example for Lesson 02

Q1

  • First get square root in x.
  • y is max round number.
  • z is positive number.
  • R is X+Z/Y.
  • (X=144, Y=2.2, Z=-33)
  • Find R?
<?php
$x = 144;
$y = 2.2;
$z = -33;
$x1 = sqrt($x);
$y1 = ceil($y);
$z1 = abs($z);
$R1 = $x1 + $z1;
$R = $R1 / $y1;
echo "R";
<?php
$x = 144;
$y = 2.2;
$z = -33;
$x1 = sqrt($x);
$y1 = ceil($y);
$z1 = abs($z);
$R1 = $x1 + $z1;
$R = $R1 / $y1;
echo "R = ";
echo $R;
?>

Thank you for all!

More php ClickHere!

See you Next php Lesson Soon!

Php Course – Worldwideasy – 01

php lesson is about php. PHP is a general-purpose scripting language. specifically designed for web development. It created by the Rasmus Lerdorf. PHP: Hypertext Preprocessor for an iterative startup.

The implementation language of php is C. It works for any OS ex: Unix, Windows.
Additional information is available at www.php.net. ATOM, Sublime Text, Php Strome as php editors. php is the server-side language.

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

  1. First we need to download php debug pack (www.php.net).
  2. After Download Extract in C Drive.
  3. Edit the System Environment Variable.
    • Environment Variable.
    • Path
    • Edit
    • New
    • Type C:php
    • Click Ok
  4. Test Using CMD
    • php -v

How to create CMD local host and run

  1. Open CMD
    • php -s localhost:4000

(example file path in Desktop file name site.php)

Open Web Browser and type this URL,

localhost:4000//www/site.php

Now you know how to run php file on your windows pc.

PHP Frameworks

What is the framework? this is software. this helps to make the website easy. it has more options to develop any program easily. It has web services, web resources, and web APIs. It helps us develop a good website. But to work with php framework you must have basic knowledge of php. See below its is top 10 php framework in 2020.

  1. Laravel
  2. Symfony
  3. Zend
  4. Yii
  5. Phalcon
  6. CodeIgniter
  7. CakePHP
  8. FuelPHP
  9. PHPixie
  10. Slim

I recommend for develop a website use CodeIgniter and Laravel it is good. I put a link below you can go it site,

How to Make First Php File

Hello World

  • First Step is Open any Shoutable editor.
  • php code have block <?php ?> any function you can type with this block.
  • php have 2 main text output method it is echo or print you can use both of them.
  • special php code line end use semicolon ( ; ).
  • See below full code of hello world in php,
<?php
echo ("Hello World");
?>

Save and run the file you can see hello world for output.

Thank you for all!

More php ClickHere!

See you Next php Lesson Soon!