|
Posted by deko on 02/12/07 00:11
>> so I have a few undefined variables... I thought this did not matter
>> with PHP (script vs. compiled code)
>>
>
> It doesn't, but it's just good practice to do so (and increasing the
> error_reporting level saves you a lot of time debugging when making typos in
> variable names).
>
Understood. Adjusting error_reporting is helpful for debugging and
optimization.
>> well, if urlString = http://netforex.subdomain.net.foo'>,
>> parse_url() returns: netforex.subdomain.net.foo'> - which is not much
>>
>
> The parse_url function can indeed easily be fooled, so you will have to add
> some additional validation. But it's quite useful for what you are doing (and
> pretty fast).
>
I'm not sure where parse_url is useful, precisely because it is so easily
fooled. The
strings I'm working with are entirely unpredictable. That's why I explode the
candidate URL into domains and inspect each one in a for loop.
>> I was able to replace an eregi with preg_match on lines 18 and 29,
>> but unsure of the syntax for line 44 ... suggestions?
>>
>
> You mean the following line?
>
>> if (eregi("^(com|net|org...)$", $urlString_a[$i]))
>
> You can simply replace this with:
>
>> if (preg_match("!^(com|net|org...)$!i", $urlString_a[$i]))
>
Thanks, but I'm still baffled by that syntax - why the second negation '!' after
the first '$' ? I understand that '$' means end of line, and 'i' means case
insensitive... is '$!' saying "not ending with"?
I still want to replace the eregi code (lines 44, 51, 55, 85) with preg_match,
but the preg_match syntax seems counter intuitive... just have not figured it
out yet. What's up with delimiters?
http://www.liarsscourge.com <<== latest code here
Thanks again for the help!
Navigation:
[Reply to this message]
|