Howto create an empty object in PHP
To create an empty object use stdClass
$obj = new \stdClass();
To create an empty object use stdClass
$obj = new \stdClass();
Remove whitespace and special chars and add dash.
Code:
$url = 'How to access to private property in php5';
$url = preg_replace("`\[.*\]`U","",$url);
$url = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$url);
$url = htmlentities($url, ENT_NOQUOTES, 'UTF-8');
$url = preg_rep...
Convert any "CamelCased" or "ordinary Word" into an "underscored_word"
Example:
$word = 'MyClassPHP';
echo strtolower(preg_replace('/[^A-Z^a-z^0-9]+/','_', preg_replace('/([a-z\d])([A-Z])/','\1_\2', preg_replace('/([A-Z]+)([A-Z][a-z])/','\1_\2',$word))));
Results:
my_class_php
Converts a word like "send_email" to "SendEmail". It will remove non aphanumeric character from the word, so "who's online" will be converted to "WhoSOnline"
Example:
$word = 'send_email';
echo str_replace(' ','',ucwords(preg_replace('/[^A-Z^a-z^0-9]+/',' ',$word)));
Result:
SendEmail
Now! with php it's easy to validate a email address. juste use this function "filter_var" with option "FILTER_VALIDATE_EMAIL" like this:
if (filter_var('contact@phphub', FILTER_VALIDATE_EMAIL)) //this return false
if (filter_var('contact@phphub.net', FILTER_VALIDATE_EMAIL)) //this return true