php如何比较php中的两个句子
我有两条线: str1=“你好,我是1”php如何比较php中的两个句子,php,html,Php,Html,我有两条线: str1=“你好,我是1” str2=“你好,我是1” 现在,我需要比较这两个句子并将其显示在标记中,我做了很多,但不知道如何在php中比较句子 <?php $str1 = "Hello, this is 1"; if ($str1 == "Hello, this is 1") { ?> <title><?= $str1 ?></title> <?php } else
str2=“你好,我是1” 现在,我需要比较这两个句子并将其显示在
标记中,我做了很多,但不知道如何在php中比较句子
<?php
$str1 = "Hello, this is 1";
if ($str1 == "Hello, this is 1")
{
?>
<title><?= $str1 ?></title>
<?php
}
else
{
?>
<title><?= $str2 ?></title>
<?php
}
?>
如何比较两个句子,如果它们相同,则显示为标题?比较两个字符串(区分大小写):
比较两个字符串(区分大小写):
比较两个字符串(区分大小写):
比较两个字符串(区分大小写):
使用strcmp()
语法:
int strcmp ( string $str1 , string $str2 )
读这里
现在,您的代码将如下所示:
<?php
$str1="Hello, this is 1";
$str2="something";
$a=strcmp($str1,$str2);
if($a==0){?> //if both strings are equal
<title><?php echo $str1?></title>
<?php }else{?>
<title><?php echo $str2?></title>
<?php }?>
//如果两个字符串相等
使用strcmp()
语法:
int strcmp ( string $str1 , string $str2 )
读这里
现在,您的代码将如下所示:
<?php
$str1="Hello, this is 1";
$str2="something";
$a=strcmp($str1,$str2);
if($a==0){?> //if both strings are equal
<title><?php echo $str1?></title>
<?php }else{?>
<title><?php echo $str2?></title>
<?php }?>
//如果两个字符串相等
使用strcmp()
语法:
int strcmp ( string $str1 , string $str2 )
读这里
现在,您的代码将如下所示:
<?php
$str1="Hello, this is 1";
$str2="something";
$a=strcmp($str1,$str2);
if($a==0){?> //if both strings are equal
<title><?php echo $str1?></title>
<?php }else{?>
<title><?php echo $str2?></title>
<?php }?>
//如果两个字符串相等
使用strcmp()
语法:
int strcmp ( string $str1 , string $str2 )
读这里
现在,您的代码将如下所示:
<?php
$str1="Hello, this is 1";
$str2="something";
$a=strcmp($str1,$str2);
if($a==0){?> //if both strings are equal
<title><?php echo $str1?></title>
<?php }else{?>
<title><?php echo $str2?></title>
<?php }?>
//如果两个字符串相等
您需要这样做
<?php
echo strcmp($string1,$string2);
?>
返回值:此函数返回:
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
0-如果两个字符串相等
0-如果string1大于string2
您需要这样做
<?php
echo strcmp($string1,$string2);
?>
返回值:此函数返回:
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
0-如果两个字符串相等
0-如果string1大于string2
您需要这样做
<?php
echo strcmp($string1,$string2);
?>
返回值:此函数返回:
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
0-如果两个字符串相等
0-如果string1大于string2
您需要这样做
<?php
echo strcmp($string1,$string2);
?>
返回值:此函数返回:
0 - if the two strings are equal
<0 - if string1 is less than string2
>0 - if string1 is greater than string2
0-如果两个字符串相等
0-如果string1大于string2
使用以下方法:
<?php if (strcmp ( $str1 , "Hello, this is 1" )==0):?>
<title><? echo $str1; ?></title>
<?php else : ?>
<title><? echo $str2; ?></title>
<?php endif; ?>
有关更多信息:请使用以下内容:
<?php if (strcmp ( $str1 , "Hello, this is 1" )==0):?>
<title><? echo $str1; ?></title>
<?php else : ?>
<title><? echo $str2; ?></title>
<?php endif; ?>
有关更多信息:请使用以下内容:
<?php if (strcmp ( $str1 , "Hello, this is 1" )==0):?>
<title><? echo $str1; ?></title>
<?php else : ?>
<title><? echo $str2; ?></title>
<?php endif; ?>
有关更多信息:请使用以下内容:
<?php if (strcmp ( $str1 , "Hello, this is 1" )==0):?>
<title><? echo $str1; ?></title>
<?php else : ?>
<title><? echo $str2; ?></title>
<?php endif; ?>
有关更多信息:您所说的比较是什么意思?你想知道它们是否相等(在同一位置有相同的字符)?@kingkero是的…如果相等equal@user3004356$str2从哪里来?它是什么类型的运算符“@RishabhRaj
等于
。检查。比较是什么意思?您想知道它们是否相等吗(在同一位置有相同的字符)?@kingkero是…如果是equal@user3004356$str2从何而来?它是什么类型的运算符“@RishabhRaj
等于
。检查。比较是什么意思?是否想知道它们是否相等(在同一位置具有相同的字符)?@kingkero是的……如果是的话equal@user3004356$str2从何而来?它是什么类型的运算符“@RishabhRaj
等于
。检查。比较是什么意思?是否想知道它们是否相等(在同一位置具有相同的字符)?@kingkero是的……如果是的话equal@user3004356$str2是从哪里来的,它是什么类型的运算符“@RishabhRaj
等于
。检查。你不是从哪里取的吗?:)也请将你的答案转换为OP实际要求的内容。@RishabhRaj我想你已经在自己的答案中转换了,所以不需要转换:)是的,我这么说是因为你比我早几秒钟回答:)+1@RishabhRaj没关系,因为你付出了更多的努力,问题已经解决了:)谢谢你不是从哪里拿走的吗?:)另外,请将您的答案转换为OP实际要求的内容。@RishabhRaj我认为您已经转换为您自己的答案,因此无需转换:)是的,我这么说是因为您比我早几秒钟回答:)+1@RishabhRaj没关系,因为你付出了更多的努力,问题已经解决了:)谢谢你不是从哪里拿走的吗?:)另外,请将您的答案转换为OP实际要求的内容。@RishabhRaj我认为您已经转换为您自己的答案,因此无需转换:)是的,我这么说是因为您比我早几秒钟回答:)+1@RishabhRaj没关系,因为你付出了更多的努力,问题已经解决了:)谢谢你不是从哪里拿走的吗?:)另外,请将您的答案转换为OP实际要求的内容。@RishabhRaj我认为您已经转换为您自己的答案,因此无需转换:)是的,我这么说是因为您比我早几秒钟回答:)+1@RishabhRaj没关系,因为你付出了更多的努力,问题已经解决:)谢谢