Skip to main content

FIX Fatal error: Call to undefined function filter_var() - filter_var alternative

Fatal error: Call to undefined function filter_var()

http://php.net/manual/en/function.filter-var.php
This function is available only for PHP 5 >= 5.2.0
http://php.net/manual/en/filter.filters.sanitize.php




<?php /*fix for older php version*/ if (!function_exists('filter_var')){ define(FILTER_VALIDATE_EMAIL,'/^[A-Za-z0-9-_.+%]+@[A-Za-z0-9-.]+.[A-Za-z]{2,4}$/'); function filter_var($string, $filter_type) { if ( preg_match( FILTER_VALIDATE_EMAIL, $string ) ) { return true; } return false; } } $val = 'argento@emailsamplex.com'; if (filter_var($val, FILTER_VALIDATE_EMAIL) === false) { die("$val wrong email");} echo 'ok';

Comments

Popular posts from this blog

2022 - Remove (the too many) Ads from Memu launcher

Simple method Download from pureapk "MEmu Launcher2" ex: MEmu Launcher2_v6.0.9_apkpure.com Install "System app remover" (root) remove from system apps the "memu launcher 2" import the "purified" MEmu Launcher2 apk with the Memu utility ("apk" on the right toolbar) Longer method Install "Export Apk" Export the memu launcher2  Install purify https://github.com/echo-devim/purify/raw/master/Purify.apk use purify with the exported memu launcher 2 Install "System app remover" (root) remove from system apps the "memu launcher 2" import the "purified" MEmu Launcher2 apk with the Memu utility ("apk" on the right toolbar)      

Database Collation when installing Opencart 3.x, 4.x

  To avoid several problems the database collation for opencart should be as follows: - for Opencart 4.0.1.1 and above it should be " utf8mb4_general_ci " - for Opencart 1.5.51 (Opencart  2.x, Opencart 3.x ) up to Opencart 4.0.1.0 the collation should be " utf8_general_ci " - for Opencart 1.4.1 up to Opencart 1.5.4.1 the collation should be " utf8_bin " - for Opencart <1.1.1 up to Opencart 1.4.0 the collation should be " utf8_unicode_ci " If you are using the latest version of mysql always use " utf8mb4_general_ci ". Never use UTF8mb3*