|
Posted by Colin Fine on 10/01/06 19:04
C. wrote:
> affiliateian@gmail.com wrote:
>> I am pretty new to php. Can anyone tell me what the proper syntax is
>> for checking a particular domain from a web form? For instance, I am
>> looking for an if statement that accomplishes this:
>>
>> if ($domain=*.mydomain.com)
>>
>> For some reason, can't get the proper syntax so that sciprt will take.
>
> try:
>
> if (fnmatch("*,mydomain.com", $domain)) {
>
> C.
>
That should read
if (fnmatch("*.mydomain.com", $domain)) {
Note that php.net says:
"For now this function is not available on Windows or other non-POSIX
compliant systems."
so if you're on such a system, you may need a more general solution:
if (preg_match('/\.mydomain.com$/', $domain)) {
which will match any string ending ".mydomain.com".
Colin
[Back to original message]
|