Day -8 Bhavik PHP SWITCH CASE bhavikphp

This is example of switch Case:-


$test = 13;

switch ($test) {

case "15" :
echo "Lucky day of my life.";
break;

case "13" :
echo "Bhavik datt birthday.";
break;

default :
echo "I love PHP.";
break;

}

Output:- Bhavik datt birthday.

Day -7 Bhavik PHP String Function with example bhavikphp


STRING REPLACE
(I)
$bhavik = str_replace("college", "school", "I love my college");
Print $bhavik;
This is output: I love my school
(II)
$numbers = array("1", "2", "3");
$words = array("one", "two", "three");
$phrase = "I have only 1 girlfriend and 3 friends";
$bhavik = str_replace($numbers, $words, $phrase);
Print $bhavik;

This is output: I have only one girlfriend and three friends
...........................................................

STRING POSITION

echo strpos("Hello BHAVIK!","BHAVIK");

output:- 6
.........................................................................................

STRING LENGTH

echo strlen("Hello BHAVIK");

output:-12
............................................................

String To Lowercase

The strtolower() function converts a string to lowercase.

echo strtolower("Hello BHAVIK.");
output:-
hello bhavik.
............................................................

SUB STRING

The substr() function returns a part of a string.
substr(string,start,length)

echo substr("Hello BHAVIK!",6);

The output :BHAVIK
!
..............................................................

STRING WORD COUNT

If you want to find out the number of words in a string, you can use str_word_count():

$bhavik = 'bhavik, dutt!';
echo str_word_count( $bhavik );

Output:- "2"
................................................................

Day -6 Bhavik PHP Function (bhavikphp)


function writename()
{
echo 'bhavik datt';
}
echo 'my name is ';
writename();
...........................................................
Output:- my name is bhavik datt

In this example writename is function and we can use like this
For your Practice I give you more example

1. Practice All Function .... DOWNLOAD

2. Function with return value.. DOWNLOAD

3. Name2 Example.... DOWNLOAD

Day -4 FOR LOOP, WHILE LOOP and DO WHILE LOOP BHAVIK PHP

"WHILE LOOP"


php
$i=1;
while($i<=5)
{
echo '
'.$i;
$i++;
}
?>
In this example we see that
1. define
2. condition
3. increment. while loop syntax,

Now "DO WHILE LOOP"

php
$i=1;
do
{
$i++;
echo '
'.$i;
}
while($i<=5);
?>

In the do while loop
1. define
2.increment
3.condition

but we are mainly use while loop

Now "FOR LOOP"

$sum=0;
for($i=1;$i<=4;$i++)
{
$sum=$sum+$i;
echo '
'.$i;
}
echo '
'.'sum = '.$sum;
?>

Output:-
1
2
3
4
sum = 10

Code Review these example FOR LOOP, WHILE and DO WHILE

1. FACTORIAL..... DOWNLOAD

2. FIBONACCI ... DOWNLOAD

3. ROOT GIVE NUMBER... DOWNLOAD

4. 10-10 GAP... DOWNLOAD

5. INVERSE NUMBER..DOWNLOAD

6. ROOT SUM.. DOWNLOAD

7. SERIES 3 MINUS. DOWNLOAD

8. SERIES 3 AND 6 . DOWNLOAD



Day -3 Bhavik PHP Operators like Arithmetic Operators , Assignment Operators ,Comparison Operators , Logical Operators

Arithmetic operators

PHP features arithmetic operator

SymbolNameExampleResult
+additionecho 7 + 512
-subtractionecho 7 - 52
*multiplicationecho 7 * 535
/divisionecho 7 / 51.4
%modulusecho 7 % 52

Comparison operators

PHP's comparison operators compare 2 values, if the comparison succee producing a Boolean result of true, or false if it failed. you are use with if...else and while loop etc.
PHP comparison operators

SymbolNameUsageResult
==equal toa == btrue if a equals b, otherwise false
!=not equal toa != btrue if a does not equal b, otherwise false
===identical toa === btrue if a equals b and they are of the same type, otherwise false
!==not identical toa !== btrue if a does not equal b or they are not of the same type, otherwise false
<less thana < btrue if a is less than b, otherwise false
>greater thana > btrue if a is greater than b, otherwise false
<=less than or equal toa <= btrue if a is less than or equal to b, otherwise false
>=greater than or equal toa >= btrue if a is greater than or equal to b, otherwise false

Logical operators


PHP logical operators:

SymbolNameExampleResult
&&anda && btrue if a and b are true, otherwise false
andanda and btrue if a and b are true, otherwise false
||ora || btrue if a or b are true, otherwise false
orora or btrue if a or b are true, otherwise false
xorxora xor btrue if a or b — but not both — are true, otherwise false
!not!atrue if a is false; false if a is true

Assignment operators

$p=5;
$p+=1;
echo 'sum = '.$p;

$q=5;
$q-=1;
echo '
sub ='.$q;

$r=5;
$r*=5;
echo '
mult='.$r;

$s=5;
$s/=5;
echo '
div='.$s;
----------------------------------------------------
Output:-

sum = 6
sub =4
mult=25
div=1
************************************************
If you competed these all task so now you code review these example like Calculator,
value is odd than or even than,
value is positive or negative
so download these example and review of code...

1. Calculator...........

........Download

2. Value is odd or even than....

........Download

3. Value is positive or negative.....

........Download

Day -2 PHP Introduction and Variable, Strings concatenation

Introduction

What is PHP???

PHP: Hypertext Preprocessor (the name is a recursive acronym) is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. ...
------------------------------------------------------------------------
Now we are start PHP with Variable define....
alway start with $ sign

$variable_name = value;
$sum = 10;
-----------------------------------

String and String concatenation in PHP


:-In the concatenation we can use (.)
and any string is apply is "" or ''


$first='BhavikPHP';
echo $first;
$second='Datt';
echo "This is concat for two string:---".$second.$first;
?>


0utput

BhavikPHP
This is concat for two string:---DattBhavikPHP

Day -1 HTLM Tags learning and Form Design

Hi friends do you ready for learning PHP??
so we are start first step HML Tag and form design,
Student information form
**********************************************
----------------------------------------------------
Output:-

Download This HTML Code:- Download

Older Posts