Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 759968f

Browse files
functions
1 parent 9d2f446 commit 759968f

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

‎functions.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
// php function..
4+
5+
function task(){
6+
return "This is task to do add two numbers";
7+
}
8+
9+
// $task = task();
10+
// print_r($task);
11+
$number = 10;
12+
function add(int $number_1){
13+
return $number+$number_1;
14+
}
15+
16+
// $sum = add(5,10);
17+
18+
// print_r(add(10));
19+
20+
function greet(string $name = 'Harry'){
21+
return "Hey, $name I am greet function";
22+
}
23+
// print_r(greet('Deepak'));
24+
25+
// built in functions
26+
// print_r, is_array, strlen, is_null, gettype, date
27+
28+
// print_r() ... data user interface pr print show krata hai
29+
30+
31+
// is_array it validates the given is array or not..
32+
33+
// true or false
34+
35+
$data = "String...";
36+
$number_list = [1,23,4234,123123,352345];
37+
$validate = is_array($number_list);
38+
39+
$null = NULL;
40+
$len = strlen($data);
41+
42+
43+
$check = is_null($number_list);
44+
45+
$type = gettype($check);
46+
47+
$cutrrent_date_time = date("Y-m-d H:i:s");
48+
print_r($cutrrent_date_time);
49+
50+
51+
?>

‎infro_function.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
// sum, gettype, sort, array...
4+
5+
function greet(){
6+
// proforming any action
7+
print_r('Hey there.. function called');
8+
}
9+
10+
11+
greet();
12+
13+
// 10,000 functions in php
14+
?>

‎switch_case.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
// switch & case
4+
5+
// break ... jump outside from current statment
6+
// switch (n){
7+
// case condition_1:
8+
// // code to exe
9+
// break;
10+
// case condition_2:
11+
// // code for condition 2
12+
// break;
13+
// case condition_3:
14+
// // code for condition 3
15+
// break;
16+
// default:
17+
// // code to exe in default mode
18+
// break;
19+
20+
// }
21+
22+
$variable = true;
23+
24+
switch (gettype($variable)) {
25+
case "string":
26+
print_r('Variable is string');
27+
break;
28+
case "integer":
29+
print_r('Variable is integer');
30+
break;
31+
case "double":
32+
print_r("variable is double");
33+
break;
34+
default:
35+
print_r('Type is not defined!');
36+
break;
37+
}
38+
$a=0;
39+
while ($a <= 10) {
40+
# code...
41+
if ($a === 5) {
42+
# code...
43+
break;
44+
}else{
45+
print_r("number $a");
46+
print_r("\n");
47+
}
48+
$a++;
49+
}
50+
51+
?>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /