Empty variables causing strict php errors
-
Not sure if this is the write answer as i didnt really look at how this function was being used just at fixing the error but something like this should work
public static function fromString( $string ) { $url = new WordPressHTTPS_Url; @preg_match_all('/((http|https):\/\/[^\'"]+)[\'"\)]?/i', $string, $url_parts); if ( isset($url_parts[1][0]) ) { if ( $url_parts = parse_url( $url_parts[1][0] ) ) { $url->setScheme(@ !empty($url_parts['scheme']) ? $url_parts['scheme'] : NULL); $url->setUser(@ !empty($url_parts['user']) ? $url_parts['user'] : NULL); $url->setPass(@ !empty($url_parts['pass']) ? $url_parts['pass'] : NULL); $url->setHost(@ !empty($url_parts['host']) ? $url_parts['host'] : NULL); $url->setPort(@ !empty($url_parts['port']) ? $url_parts['port'] : NULL); $url->setPath(@ !empty($url_parts['path']) ? $url_parts['path'] : NULL); $url->setQuery(@ !empty($url_parts['query']) ? $url_parts['query'] : NULL); $url->setFragment(@ !empty($url_parts['fragment']) ? $url_parts['fragment'] : NULL); return $url; } } else { return false; } return $url; }That function is in lib\WordPressHTTPS\Url.php
Fixes the Undefined index: errors
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Empty variables causing strict php errors’ is closed to new replies.