Php 如何检查字符串是否有英文字母

Php 如何检查字符串是否有英文字母,php,Php,在stackoverflow上有很多问题,他们说如果字符串只包含英文字母。但我想知道如何检查字符串是否有英文字母: 例: 使用 示例:- <?php $subject = "abcdef"; $pattern = '/^def/'; preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> wrt问题是这样的: <?php $string = "

在stackoverflow上有很多问题,他们说如果字符串只包含英文字母。但我想知道如何检查字符串是否有英文字母:

例:

使用

示例:-

<?php
$subject = "abcdef";
$pattern = '/^def/';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
?>
wrt问题是这样的:

<?php
$string = "で書くタッチイベント B A(フ";
$pattern = '/[a-zA-Z]/';
preg_match($pattern, $string, $matches);
print_r($matches);
?>
preg_match,看看你是否可以在任何地方匹配一个英文字母。可能类似于if preg_match_all'/[A-Za-z]/',$string
<?php
$string = "で書くタッチイベント B A(フ";
$pattern = '/[a-zA-Z]/';
preg_match($pattern, $string, $matches);
print_r($matches);
?>