यह जांचने के लिए कि क्या किसी स्ट्रिंग में कोई व्हाइटस्पेस नहीं है, PHP में preg_match() का उपयोग करें।
सिंटैक्स इस प्रकार है:
preg_match('/\s/',$yourVariableName);
उदाहरण
PHP कोड इस प्रकार है:
<!DOCTYPE html>
<html>
<body>
<?php
$name="John Smith";
if ( preg_match('/\s/',$name) ){
echo "The name (",$name,") has the space";
} else {
echo "The Name (",$name,") has not the space";
}
?>
</body>
</html>
आउटपुट
The name (John Smith) has the space