0

Im so so new to php and sry for my begginer question .

<?php
        $Sal = "HI";
        if (preg_match("[a-zA-Z][a-zA-Z]",$Sal)) echo "hi";

        ?>

this is my code , why doesent the preg_match run and echo "hi"? thank you

4
Contributors
7
Replies
8
Views
4 Years
Discussion Span
Last Post by ryantroop
0

NO , Nothing just an empty page and know its like this with yours but no answer

<!DOCTYPE html>
<html>
    <head>


        <title></title>
    </head>
    <body>
        <p>  </p>

        <?php
        $Sal = "HI";
        if (preg_match("/[^a-zA-Z ]/",$Sal)) echo "hi";

        ?>
    </body>
</html>
0

ok, now I tested this and it worked

if (preg_match("/[^a-zA-Z ]/",$Sal)==0) echo "hi";

Edited by ainosilva

0

(preg_match("/[^A-Z ]/",$Sal)==0) Now everything echos like If I change $sal to hh it will echo but if you mention it should have a uppercase that it doesent have

2

@kshahnazari

Try this:

<?php
$Sal = "HI";

if (preg_match ('/[a-zA-Z][a-zA-Z]$/',$Sal)) {

echo "\nhi\n"; 
  }
?>

Edited by LastMitch: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.