Apa yang diatur dalam php?

Ds\Set. berisi () fungsi adalah fungsi bawaan di PHP yang digunakan untuk memeriksa nilai yang diberikan ada di set atau tidak. Fungsi ini membandingkan nilai dan tipenya

Sintaksis

bool public Ds\Set::contains( $values )

Parameter. Fungsi ini menerima satu atau banyak nilai yang perlu diperiksa nilai yang ada di set atau tidak

Nilai pengembalian. Jika nilai ada di set maka itu mengembalikan True jika tidak mengembalikan False

Program di bawah mengilustrasikan Ds\Set. berisi () fungsi dalam PHP

Program 1




<?php 

 

// Declare new Set

$set =new \Ds\Set([

bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
0
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
1
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
2
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
1
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
2
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
1_______1
bool(true)
bool(true)
bool(false)
bool(true)
bool(false)
6________1______1_______1_______8________1_____

Fungsi isset () adalah fungsi bawaan di PHP yang memeriksa apakah suatu variabel disetel dan bukan NULL. Fungsi ini juga memeriksa apakah variabel yang dideklarasikan, array atau kunci array memiliki nilai null, jika ya, isset() mengembalikan false, mengembalikan true dalam semua kemungkinan kasus lainnya

Sintaksis.  

bool isset( $var, mixed )

Parameter. Fungsi ini menerima lebih dari satu parameter. Parameter pertama dari fungsi ini adalah $var. Parameter ini digunakan untuk menyimpan nilai variabel

Contoh.   

PHP




<?php

 

// PHP program to illustrate

// isset() function

$num ='0'

0 is set with isset function 
array is not set.
0

 

________12______1

0 is set with isset function 
array is not set.
2$num
0 is set with isset function 
array is not set.
4

0 is set with isset function 
array is not set.
5
0 is set with isset function 
array is not set.
6
0 is set with isset function 
array is not set.
7
0 is set with isset function 
array is not set.
8

0 is set with isset function 
array is not set.
_9

 

0 is considered empty
1 is considered set
0

0 is considered empty
1 is considered set
1 =
0 is considered empty
1 is considered set
3
0 is considered empty
1 is considered set
4

0 is considered empty
1 is considered set
5

0 is considered empty
1 is considered set
6

0 is considered empty
1 is considered set
7
0 is considered empty
1 is considered set
8
0 is considered empty
1 is considered set
1
0 is set with isset function
1 is set with !empty function
0
0 is set with isset function
1 is set with !empty function
1
0 is set with isset function
1 is set with !empty function
2

0 is set with isset function
1 is set with !empty function
3
0 is set with isset function
1 is set with !empty function
4
0 is set with isset function
1 is set with !empty function
5
0 is set with isset function 
array is not set.
0

0 is set with isset function
1 is set with !empty function
7

Keluaran.

0 is set with isset function 
array is not set.

 

kosong() Fungsi

Fungsi empty() adalah konstruksi bahasa untuk menentukan apakah variabel yang diberikan kosong atau NULL. Itu. fungsi empty() adalah negasi atau komplemen dari fungsi empty(). Fungsi empty() sangat mirip dengan. fungsi isset() dan. fungsi empty() sama dengan fungsi isset()

Contoh.   

PHP




<?php

 

// PHP program to illustrate

<?php0

 

<?php1 <?php2

 

<?php_3

<?php_4

0 is set with isset function 
array is not set.
1 <?php6<?php7<?php6________80______1// PHP program to illustrate0

________12______5

0 is considered empty
1 is considered set
7 <?php1 // PHP program to illustrate4// PHP program to illustrate5
0 is set with isset function 
array is not set.
0

0 is set with isset function 
array is not set.
_9

 

0 is considered empty
1 is considered set
7 // PHP program to illustrate9
0 is set with isset function 
array is not set.
0

 

// isset() function1

// isset() function2 // isset() function3

0 is set with isset function 
array is not set.
1 // isset() function5<?php7<?php6// isset() function2// PHP program to illustrate0

________12______5

0 is considered empty
1 is considered set
7 // isset() function2 // PHP program to illustrate4________83______4
0 is set with isset function 
array is not set.
0

0 is set with isset function 
array is not set.
_9

0 is set with isset function
1 is set with !empty function
7

Keluaran.

0 is considered empty
1 is considered set

 

Alasan untuk memeriksa kedua fungsi.  
isset() dan. fungsi empty() serupa dan keduanya akan mengembalikan hasil yang sama. Tapi satu-satunya perbedaan adalah. fungsi empty() tidak akan menghasilkan peringatan atau e-notice ketika variabel tidak ada. Cukup menggunakan salah satu dari fungsi tersebut. Dengan menggabungkan kedua fungsi tersebut dalam sebuah program menyebabkan selang waktu dan penggunaan memori yang tidak perlu

Contoh.   

PHP




<?php

 

$num_9

=_0

 

=_1

$num ='0'

0 is set with isset function 
array is not set.
0

 

=_6

________12______1=8$num

0 is set with isset function 
array is not set.
4

________12______5

0 is set with isset function 
array is not set.
6$num // PHP program to illustrate4'0'5
0 is set with isset function 
array is not set.
8

0 is set with isset function 
array is not set.
_9

 

'0'8

0 is considered empty
1 is considered set
7 // PHP program to illustrate9
0 is set with isset function 
array is not set.
0

 

0 is set with isset function 
array is not set.
_02

$num // isset() function3

 

0 is set with isset function 
array is not set.
_05

________12______1

0 is set with isset function 
array is not set.
07<?php7 <?php6$num
0 is set with isset function 
array is not set.
4

________12______5

0 is set with isset function 
array is not set.
6$num // PHP program to illustrate4
0 is set with isset function 
array is not set.
16
0 is set with isset function 
array is not set.
8

0 is set with isset function 
array is not set.
_9

Keluaran.

0 is set with isset function
1 is set with !empty function

 

PHP adalah bahasa skrip sisi server yang dirancang khusus untuk pengembangan web. Anda dapat mempelajari PHP dari bawah ke atas dengan mengikuti Tutorial PHP dan Contoh PHP ini

Apakah ada yang diatur dalam PHP?

Redis dan PHP Set adalah rangkaian nilai unik , dan implementasi ini dapat menggunakan tabel hash yang sama dengan Ds\Map di mana nilainya .

Apakah mengatur array PHP?

Fungsi isset() adalah fungsi bawaan dalam PHP yang memeriksa apakah suatu variabel disetel dan bukan NULL . Fungsi ini juga memeriksa apakah variabel yang dideklarasikan, array atau kunci array memiliki nilai null, jika ya, isset() mengembalikan false, mengembalikan true dalam semua kemungkinan kasus lainnya.

Apa itu $_GET di PHP?

PHP $_GET adalah variabel super global PHP yang digunakan untuk mengumpulkan data formulir setelah mengirimkan formulir HTML dengan method="get" . $_GET juga dapat mengumpulkan data yang dikirim dalam URL.

Apa yang kosong () di PHP?

Fungsi empty() memeriksa apakah suatu variabel kosong atau tidak . Fungsi ini mengembalikan false jika variabel ada dan tidak kosong, jika tidak maka mengembalikan true.