-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp.html
4129 lines (4029 loc) · 120 KB
/
php.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<!-- ad sense tag-->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1733919132650092"
crossorigin="anonymous"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FBJL1SB5QM"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-FBJL1SB5QM");
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="title" content="Coding-nation" />
<meta name="description"
content="CodingNation is a comprehensive code tutorial website, providing beginner to advanced coding tutorials, coding exercises, and coding challenges to help you learn to code and build your skills." />
<meta name="keywords"
content="Coding-nation, CodeNation, HTML tutorials, python tutorials, css tutorials, c tutorials,React js tutorials, javascript tutorials,java tutorials, php tutorials, code editor, online code editor, Codebot,chatbot,quizzes" />
<meta name="robots" content="index, follow" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="English" />
<meta name="author" content="coding-nation.com" />
<title>PHP Course | coding-nation</title>
<link rel="icon" type="image/png" sizes="32x32" href="../images/favicon.png" />
<!-- Latest compiled and minified CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Latest compiled JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://unpkg.com/[email protected]/css/boxicons.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" rel="stylesheet" />
<link rel="stylesheet" href="../Styles/Notes.css" />
<script>
function changeTitle(newTitle) {
document.title = newTitle;
}
</script>
</head>
<body>
<!--for whole page-->
<div class="contain">
<!--navigation bar-->
<header class="fixed-navbar">
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="../index.html">CodingNation</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto" id="navbarNavLinks">
<li class="nav-item">
<a class="nav-link" href="../index.html">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">Courses</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="../Python.html">Python</a>
</li>
<li>
<a class="dropdown-item" href="../React.html">React JS</a>
</li>
<li>
<a class="dropdown-item" href="../html.html">HTML</a>
</li>
<li><a class="dropdown-item" href="../css.html">CSS</a></li>
<li>
<a class="dropdown-item" href="../jascri.html">JavaScript</a>
</li>
<li><a class="dropdown-item" href="../cpro.html">C</a></li>
<li>
<a class="dropdown-item" href="../java.html">Java</a>
</li>
<li><a class="dropdown-item" href="../php.html">PHP</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Practice</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="../HTMLQuiz.html" target="_blank">HTML
Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../CSSQuiz.html" target="_blank">CSS
Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../JSQuiz.html" target="_blank">JavaScript
Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../CQuiz.html" target="_blank">C Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../JAVAQuiz.html" target="_blank">Java
Quiz</a>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button"
data-bs-toggle="dropdown">Exercises</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="../HTMLExer.html" target="_blank">HTML Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../CSSExer.html" target="_blank">CSS Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../JsExer.html" target="_blank">JavaScript
Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../CExer.html" target="_blank">C Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../JAVAExer.html" target="_blank">Java Exercise</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="../codebot.html" target="_blank">CodeBot</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../Editor.html" target="_blank">Editor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../About.html">About</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--sidebar-->
<button class="topics" onclick="toggleSidebar()">Topics▼</button>
<aside class="fixed-sidebar" id="myNav">
<div class="menu">
<h2>Introduction</h2>
<button class="single" data-index="0" onclick="changeTitle('PHP Overview | CodingNation')">
PHP Overview
</button>
<button class="single" data-index="1" onclick="changeTitle('PHP Comments | CodingNation')">
PHP Comments
</button>
<button class="single" data-index="2" onclick="changeTitle('Variabels in PHP | CodingNation')">
Variabels in PHP
</button>
<button class="single" data-index="3" onclick="changeTitle('Variabel Scope | CodingNation')">
Variabel Scope
</button>
<h2>Data Types & Operators</h2>
<button class="single" data-index="4" onclick="changeTitle('PHP DataTypes | CodingNation')">
PHP DataTypes
</button>
<button class="single" data-index="5" onclick="changeTitle('PHP Operators | CodingNation')">
PHP Operators
</button>
<h2>Conditional & Iterative Statements</h2>
<button class="single" data-index="6" onclick="changeTitle('PHP Conditional Statements | CodingNation')">
PHP Conditional<br />Statements
</button>
<button class="single" data-index="7" onclick="changeTitle('PHP Iterative Statements | CodingNation')">
PHP Iterative Statements
</button>
<h2>PHP Functions</h2>
<button class="single" data-index="8" onclick="changeTitle('Function Basics | CodingNation')">
Function Basics
</button>
<button class="single" data-index="9" onclick="changeTitle('Function Arguments | CodingNation')">
Function Arguments
</button>
<h2>PHP Arrays</h2>
<button class="single" data-index="10" onclick="changeTitle('Arrays | CodingNation')">
Arrays
</button>
<h2>PHP OOPS</h2>
<button class="single" data-index="11" onclick="changeTitle('Introduction to OOPS | CodingNation')">
Introduction to OOPS
</button>
<button class="single" data-index="12" onclick="changeTitle('Classes | CodingNation')">
Classes
</button>
<button class="single" data-index="13" onclick="changeTitle('Objects | CodingNation')">
Objects
</button>
<button class="single" data-index="14" onclick="changeTitle('Access Modifiers | CodingNation')">
Access Modifiers
</button>
<button class="single" data-index="15" onclick="changeTitle('Constructors and Destructors | CodingNation')">
Constructors and<br />Destructors
</button>
<button class="single" data-index="16" onclick="changeTitle('Inheritance | CodingNation')">
Inheritance
</button>
<button class="single" data-index="17" onclick="changeTitle('Interface | CodingNation')">
Interface
</button>
<button class="single" data-index="18" onclick="changeTitle('Abstract Classes | CodingNation')">
Abstract Classes
</button>
<button class="single" data-index="19" onclick="changeTitle('Class Constants | CodingNation')">
Class Constants
</button>
<button class="single" data-index="20" onclick="changeTitle('Traits | CodingNation')">
Traits
</button>
<button class="single" data-index="21" onclick="changeTitle('Static Methods | CodingNation')">
Static Methods
</button>
<button class="single" data-index="22" onclick="changeTitle('Static Properties | CodingNation')">
Static Properties
</button>
<h2>PHP Superglobals</h2>
<button class="single" data-index="23" onclick="changeTitle('Superglobals | CodingNation')">
Superglobals
</button>
<button class="single" data-index="24" onclick="changeTitle('$GLOBALS | CodingNation')">
$GLOBALS
</button>
<button class="single" data-index="25" onclick="changeTitle('$_SERVER | CodingNation')">
$_SERVER
</button>
<button class="single" data-index="26" onclick="changeTitle('$_REQUEST | CodingNation')">
$_REQUEST
</button>
<button class="single" data-index="27" onclick="changeTitle('$_POST | CodingNation')">
$_POST
</button>
<button class="single" data-index="28" onclick="changeTitle('$_GET | CodingNation')">
$_GET
</button>
<button class="single" data-index="29" onclick="changeTitle('$GLOBAL | CodingNation')">
$GLOBAL
</button>
<button class="single" data-index="30" onclick="changeTitle('$_COOKIE | CodingNation')">
$_COOKIE
</button>
<button class="single" data-index="31" onclick="changeTitle('$_SESSION | CodingNation')">
$_SESSION
</button>
<h2>PHP MySQL</h2>
<button class="single" data-index="32" onclick="changeTitle('Introduction | CodingNation')">
Introduction
</button>
<button class="single" data-index="33" onclick="changeTitle('Connecting to MySQL | CodingNation')">
Connecting to MySQL
</button>
<button class="single" data-index="34" onclick="changeTitle('Creating a MySQL Database | CodingNation')">
Creating a MySQL<br />Database
</button>
<button class="single" data-index="35" onclick="changeTitle('Creating Table in MySQL | CodingNation')">
Creating Table in MySQL
</button>
<button class="single" data-index="36" onclick="changeTitle('Inserting Data in MySQL | CodingNation')">
Inserting Data in MySQL
</button>
<button class="single" data-index="37" onclick="changeTitle('Inserting Data in MySQL | CodingNation')">
Inserting Data in MySQL
</button>
<button class="single" data-index="38" onclick="changeTitle('Updating Data in MySQL | CodingNation')">
Updating Data in MySQL
</button>
<button class="single" data-index="39" onclick="changeTitle('Deleting Data in MySQL | CodingNation')">
Deleting Data in MySQL
</button>
<h2>PHP Advance Topics</h2>
<button class="single" data-index="40" onclick="changeTitle('Include & Require | CodingNation')">
Include & Require
</button>
<button class="single" data-index="41" onclick="changeTitle('$File Handling | CodingNation')">
File Handling
</button>
</div>
</aside>
<!--for content side-->
<main class="main-content">
<div class="content">
<!--previous and next buttons-->
<button id="previous">Previous</button>
<button id="next">Next</button>
<!--Notes-->
<div class="notes" id="div1">
<h2>PHP Overview</h2>
<br />
<p>
PHP is a server-side scripting language, which is used to manage
dynamic web pages, databases and build websites with features like
session tracking and e-commerce. On a day of 1995, Rasmus Lerdorf
unleashed the first version of “Hypertext Preprocessor” also known
as the PHP language. It is also integrated with several popular
databases like MySQL, PostgreSQL, Microsoft SQL Server, Oracle
etc.
</p>
<br />
<br />
<h3>Uses of PHP</h3>
<br />
<p>
PHP can perform several system functions like opening files, CRUD
operations on data stores, general-purpose scripting, etc. Besides
system operations, there are also other uses like
</p>
<br />
<li>
<b>Handling Forms:</b> PHP can handle form operations. It can
gather data, save data to a file and send data through emails.
</li>
<li>
<b>Database Operations:</b> PHP can also create, read, update and
delete elements in your database.
</li>
<li>
<b>Encryption:</b> It can perform advanced encryption and encrypt
data for you.
</li>
<li>
<b>Dynamic Page Content:</b> It can generate dynamic page content.
</li>
<br />
<br />
<h3>Basic Syntax PHP</h3>
<br />
<p>
A PHP script can be written anywhere inside the HTML document. A
PHP script starts with <?php tag and ends with ?>. We can
write our logic inside this tag and it will be executed
accordingly.
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
// PHP code goes here
?>
</code>
</pre>
<br />
<br />
<h3>Displaying output in php</h3>
<br />
<p>
In php,Output is displayed on the browser using echo as follows:
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
echo "hello";
?>
</code>
</pre>
<br />
<br />
<h3>Hello World</h3>
<br />
<p>
A basic PHP Hello World program looks something like this. We will
use a built-in PHP function “echo” to output the text “Hello
World!” on our webpage.
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
</code>
</pre>
<br />
<br />
</div>
<div class="notes" id="div2" style="display: none">
<h2>PHP Comments</h2>
<br />
<p>
A comment is a part of the coding file that the programmer does
not want to execute, rather the programmer uses it to either
explain a block of code or to avoid the execution of a specific
part of code while testing.
</p>
<br />
<br />
<h3>PHP supports several ways of commenting:</h3>
<br />
<h4>Single Line Comments</h4>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
// This is a single-line comment
# This is also a single-line comment
?>
</code>
</pre>
<br />
<br />
<h4>Multiple-Line Comments</h4>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
/*
This is a
multiple line
Comment.
*/
?>
</code>
</pre>
<br />
<br />
</div>
<div class="notes" id="div3" style="display: none">
<h2>Variables in PHP</h2>
<br />
<p>
<b>Variables are containers that can store information which can
be manipulated or referenced later by the programmer within the
code.</b>
</p>
<br />
<br />
<p>
In PHP, we don’t need to declare the variable type explicitly. The
type of variable is determined by the value it stores. There are
some important things to know about variables in PHP.
</p>
<br />
<li>All variables should be denoted with a Dollar Sign ($)</li>
<li>
Variables are assigned with the = operator, with the variable on
the left-hand side and the expression to be evaluated on the
right.
</li>
<li>
Variable names can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ ).
</li>
<li>
Variables must start with a letter or the underscore “_”
character.
</li>
<li>Variables are case sensitive</li>
<li>Variable names cannot start with a number.</li>
<br />
<br />
<b>For Example:</b><br />
<pre class="highlight">
<code class="language-PHP">
<?php
$txt = "Hello world!"; # Type String
$x = 5; # Type int
$y = 10.5; # Type Float
?>
</code>
</pre>
<br />
<br />
</div>
<div class="notes" id="div4" style="display: none">
<h2>Variable Scope</h2>
<br />
<p>
The scope of the variable is the area within which the variable
has been created. Based on this a variable can either have a local
scope or a global scope or a static scope in PHP.
</p>
<br />
<br />
<h3>Global Variable:</h3>
<br />
<p>
A variable which was created in the main body of the code and that
can be accessed anywhere in the program is called Global Variable.
Global variables can be directly accessed or used in or outside of
a function with GLOBAL keyword before variable. However, we can
also call them without the global keyword.
</p>
<br />
<b>For Example:</b><br />
<pre class="highlight">
<code class="language-PHP">
<?php
$name = "Harry Bhai"; //Global Variable
function global_var()
{
global $name;
echo "Variable inside the function: ". $name;
echo "</br>";
}
global_var();
echo "Variable outside the function: ". $name;
?>
</code>
</pre>
<br />
<br />
<h4>Output:</h4>
<br />
<pre class="highlight">
<code class="language-PHP">
Variable inside the function: Nikhil
Variable outside the function: Nikhil
</code>
</pre>
<br />
<br />
<h3>Local Variabel:</h3>
<br />
<p>
A local variable is created within a function and can be only used
inside the function. This means that these variables cannot be
accessed outside the function, as they have local scope.
</p>
<br />
<h3>For Example:</h3>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
function mytest()
{
$capital = "Delhi";
echo "Capital of India is: " .$capital;
}
mytest(); //Calling the function
//using $capital outside the function will generate an error
echo $capital;
?>
</code>
</pre>
<br />
<br />
<h4>Output:</h4>
<br />
<pre class="highlight">
<code class="language-PHP">
Capital of India is: Delhi Notice: Undefined variable: capital in D:\xampp\htdocs\program\var.php on line 28
</code>
</pre>
<br />
<br />
<h3>Static Variable:</h3>
<br />
<p>
PHP has a feature that deletes the variable once it has finished
execution and frees the memory. When we need a local variable
which can store its value even after the execution, we use the
static keyword before it and the variable is called static
variable.
<br />
These variables only exist in a local function and do not get
deleted after the execution has been completed.
</p>
<br />
<h3>For Example:</h3>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
function static_var()
{
static $num1 = 3; //static variable
$num2 = 6; //Non-static variable
//increment in non-static variable which will increment its value to 7
$num1++;
//increment in static variable which will increment its value to 4 after first execution and 5 after second execution
$num2++;
echo "Static: " .$num1 ."</br>";
echo "Non-static: " .$num2 ."</br>";
}
//first function call
static_var();
//second function call
static_var();
?>
</code>
</pre>
<br />
<br />
<h4>Output:</h4>
<br />
<pre class="highlight">
<code class="language-PHP">
Static: 4
Non-static: 7
Static: 5
Non-static: 7
</code>
</pre>
<br />
<br />
</div>
<div class="notes" id="div5" style="display: none">
<h2>PHP Data Types</h2>
<br />
<p>
Data type specifies the type of value a variable requires to do
various operations without causing an error. By default, PHP
provides the following built-in data types:
</p>
<br />
<li>String</li>
<li>Integer</li>
<li>Float</li>
<li>Boolean</li>
<li>Array</li>
<li>NULL</li>
<br />
<br />
<h3>1. String</h3>
<br />
<p>
A string is a sequence of characters that holds letters and
numbers. It can be anything written inside single or double
quotes.
</p>
<br />
<h4>For Example</h4>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
$x = "Hello world!";
echo $x;
?>
</code>
</pre>
<br />
<br />
<h3>2.Integer</h3>
<br />
<p>
An integer is a non-decimal number typically ranging between
-2,147,483,648 and 2,147,483,647.
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
$x = 55;
var_dump($x);
?>
</code>
</pre>
<br />
<br />
<h3>3.Float</h3>
<br />
<p>
A float is a number with a decimal point. It can be an exponential
number or a fraction.
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
$x = 52.55;
var_dump($x);
?>
</code>
</pre>
<br />
<br />
<h3>4. Boolean</h3>
<br />
<p>A Boolean represents two values: True or False.</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
$x = true;
$y = false;
?>
</code>
</pre>
<br />
<br />
<h3>5.Array</h3>
<br />
<p>
Array is a collection of similar data elements stored in a single
variable.
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
$x =array("Chandra", "Nithin", "Nikhil");
var_dump($x);
?>
</code>
</pre>
<br />
<br />
<h3>6. NULL</h3>
<br />
<p>
Null is a special data type with only one value which is NULL. In
PHP, if a variable is created without passing a value, it will
automatically assign itself a value of NULL.
</p>
<br />
<pre class="highlight">
<code class="language-PHP">
<?php
$x = null;
?>
</code>
</pre>
<br />
<br />
</div>
<div class="notes" id="div6" style="display: none">
<h2>PHP Operators</h2>
<br />
<p>
PHP has different types of operators for different operations.
They are as follows:
</p>
<br />
<br />
<h3>1. Arithmetic Operators</h3>
<br />
<p>
Arithmetic operators are used to perform arithmetic operations.
</p>
<br />
<table>
<tr>
<th>Name</th>
<th>Operator</th>
<th>Example</th>
</tr>
<tr>
<td>Addition</td>
<td>+</td>
<td>$x+$y</td>
</tr>
<tr>
<td>Subraction</td>
<td>-</td>
<td>$x-$y</td>
</tr>
<tr>
<td>Multiplication</td>
<td>*</td>
<td>$x*$y</td>
</tr>
<tr>
<td>Division</td>
<td>/</td>
<td>$x/$y</td>
</tr>
<tr>
<td>modulus</td>
<td>%</td>
<td>$x%$y</td>
</tr>
<tr>
<td>Exponentiation</td>
<td>**</td>
<td>$x**$y</td>
</tr>
</table>
<br />
<br />
<h3>2.Assignment Operators</h3>
<br />
<p>These operators are used to assign values to variables.</p>
<br />
<table>
<tr>
<th>Name</th>
<th>Evaluated as</th>
</tr>
<tr>
<td>=</td>
<td>a=b</td>
</tr>
<tr>
<td>+=</td>
<td>a=a+b</td>
</tr>
<tr>
<td>-=</td>
<td>a=a-b</td>
</tr>
<tr>
<td>*=</td>
<td>a=a*b</td>
</tr>
<tr>
<td>/=</td>
<td>a=a/b</td>
</tr>
<tr>
<td>%=</td>
<td>a=a%b</td>
</tr>
</table>
<br />
<br />
<h3>3.Comparison Operators</h3>
<br />
<p>These operators are used to compare two values.</p>
<br />
<table>
<tr>
<th>Name</th>
<th>Operator</th>
<th>Example</th>
</tr>
<tr>
<td>Equal</td>
<td>==</td>
<td>$x==$y</td>
</tr>
<tr>
<td>Identical</td>
<td>===</td>
<td>$x===$y</td>
</tr>
<tr>
<td>Not equal</td>
<td>!=</td>
<td>$x!=$y</td>
</tr>
<tr>
<td>Not equal</td>
<td><></td>
<td>$x<>$y</td>
</tr>
<tr>
<td>Not Identical</td>
<td>!===</td>
<td>$x!===$y</td>
</tr>
<tr>
<td>Greater than</td>
<td>></td>
<td>$x>$y</td>
</tr>
<tr>
<td>Less than</td>
<td><</td>
<td>$x<$y</td>
</tr>
<tr>
<td>Greater than or equal to</td>
<td>>=</td>
<td>$x>=$y</td>
</tr>
<tr>
<td>Less than or equal to</td>
<td><</td>
<td>$x<=$y</td>
</tr>
<tr>
<td>Spaceship</td>
<td><=></td>
<td>$x<=>$y</td>
</tr>
</table>
<br />
<br />
<h3>4. PHP Increment/Decrement Operators</h3>
<br />
<p>
These operators are used to increment/ decrement variable’s value.
</p>
<br />
<table>
<tr>
<th>Name</th>
<th>Operator</th>
</tr>
<tr>
<td>Pre-Increment</td>
<td>++$x</td>
</tr>
<tr>
<td>Post-Increment</td>
<td>$x--</td>
</tr>
<tr>
<td>Pre-decrement</td>
<td>-$x</td>
</tr>
<tr>
<td>Post-decrement</td>
<td>$x--</td>
</tr>
</table>
<br />
<br />
<h3>5. PHP Logical Operators</h3>
<br />
<p>
These are the logical operators that combine conditional
statements.
</p>
<br />
<table>
<tr>
<th>Name</th>
<th>Operator</th>
<th>Example</th>
</tr>
<tr>
<td>And</td>
<td>and</td>
<td>$x and $y</td>
</tr>
<tr>
<td>Or</td>
<td>or</td>
<td>$x or $y</td>
</tr>
<tr>
<td>Xor</td>
<td>xor</td>
<td>$x xor $y</td>
</tr>
<tr>
<td>And</td>
<td>&&</td>
<td>$x && $y</td>
</tr>
<tr>
<td>Or</td>
<td>||</td>
<td>$x || $y</td>
</tr>
<tr>
<td>Not</td>
<td>!</td>
<td>!&x</td>
</tr>
</table>
<br />
<br />
<h3>PHP String Operators</h3>
<br />
<p>PHP has these two operators designed for strings.</p>
<br />
<table>
<tr>
<th>Name</th>
<th>Operator</th>
<th>Example</th>
</tr>
<tr>
<td>Concatention</td>
<td>.</td>
<td>$text1.$text2</td>
</tr>
<tr>
<td>Concatention assignment</td>
<td>.=</td>
<td>$text1.=$text2</td>
</tr>
</table>
<br />
<br />
<h3>7.PHP Array Operators</h3>
<br />
<p>These Operators are used to compare arrays.</p>
<br />
<table>