Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

About validateUrlSyntax(): This function will verify if a http URL is formatted properly, returning either with true or false. I used rfc #2396 URI: Generic Syntax as my guide when creating the regular expression. For all the details see the comments below.

Copyright: Copyright 2004, Rod Apeldoorn {@link http://www.canowhoopass.com/}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 555 lines (24 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 3 functions


Functions that are not part of a class:

validateUrlSyntax( $urladdr, $options="" )   X-Ref
BEGINNING OF validateUrlSyntax() function


validateEmailSyntax( $emailaddr, $options="" )   X-Ref
About ValidateEmailSyntax():
This function uses the ValidateUrlSyntax() function to easily check the
syntax of an email address. It accepts the same options as ValidateURLSyntax
but defaults them for email addresses.

Usage:
<code>
validateEmailSyntax( url_to_check[, options])
</code>
url_to_check - string - The url to check

options - string - A optional string of options to set which parts of
the url are required, optional, or not allowed. Each option
must be followed by a "+" for required, "?" for optional, or
"-" for not allowed. See ValidateUrlSyntax() docs for option list.

The default options are changed to:
s-H-S-E+F-u+P-a+I-p-f-q-r-

This only allows an address of "name@domain".

Examples:
<code>
validateEmailSyntax('george@fakemail.com')
validateEmailSyntax('mailto:george@fakemail.com', 's+')
validateEmailSyntax('george@fakemail.com?subject=Hi%20George', 'q?')
validateEmailSyntax('george@212.198.33.12', 'I?')
</code>


Author(s):
Rod Apeldoorn - rod(at)canowhoopass(dot)com


Homepage:
http://www.canowhoopass.com/


License:
Copyright 2004 - Rod Apeldoorn

Released under same license as validateUrlSyntax(). For details, contact me.

validateFtpSyntax( $ftpaddr, $options="" )   X-Ref
About ValidateFtpSyntax():
This function uses the ValidateUrlSyntax() function to easily check the
syntax of an FTP address. It accepts the same options as ValidateURLSyntax
but defaults them for FTP addresses.

Usage:
<code>
validateFtpSyntax( url_to_check[, options])
</code>
url_to_check - string - The url to check

options - string - A optional string of options to set which parts of
the url are required, optional, or not allowed. Each option
must be followed by a "+" for required, "?" for optional, or
"-" for not allowed. See ValidateUrlSyntax() docs for option list.

The default options are changed to:
s?H-S-E-F+u?P?a+I?p?f?q-r-

Examples:
<code>
validateFtpSyntax('ftp://netscape.com')
validateFtpSyntax('moz:iesucks@netscape.com')
validateFtpSyntax('ftp://netscape.com:2121/browsers/ns7/', 'u-')
</code>

Author(s):
Rod Apeldoorn - rod(at)canowhoopass(dot)com


Homepage:
http://www.canowhoopass.com/


License:
Copyright 2004 - Rod Apeldoorn

Released under same license as validateUrlSyntax(). For details, contact me.