Php องข้อความรวมถึงการ

รหัสตัวอย่าง

48
0

php ตรวจสอบว่าข้อความบรรจุคำ

$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
    echo "My string contains Bob";
}
6
0

php chech ถ้าบรรจุข้อความ

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
5
0

php เจอว่าส่วนข้อความอยู่ว่าอยู่ในข้อความ

$result = strpos("haystack", "needle");

if ($result != false)
{
  // text found
}
4
0

php หาถ้าจะบรรจุข้อความ

if (strpos($string, 'substring') !== false) {
	// do stuff 
}
2
0

ยังไงฉันตรวจสอบว่าเป็นบรรจุข้อความมีเหยื่อที่เป็นคำพูดน่ะเหรอ?

$a = 'Hello world?';

if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
    echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
    echo 'true';
}
1
0

str_includes php

<?php
$string = 'The lazy fox jumped over the fence';

if (str_contains($string, '')) {
    echo "Checking the existence of an empty string will always return true";
}

if (str_contains($string, 'lazy')) {
    echo "The string 'lazy' was found in the string\n";
}

if (str_contains($string, 'Lazy')) {
    echo 'The string "Lazy" was found in the string';
} else {
    echo '"Lazy" was not found because the case does not match';
}

# Checking the existence of the empty string will always return true
# The string 'lazy' was found in the string
# "Lazy" was not found because the case does not match
0
0

ข้อความบรรจุ php

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
0
0

มี php

if (strpos($a, 'are') !== false) {
    echo 'true';
}

หน้าคล้ายกัน

คล้ายกันหน้ากับตัวอย่าง

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังหน้ากับตัวอย่างอยู่ในหมวดหมู่