Use mb_strlen
to know how many characters you have and compare with the minimum number of characters required.
For example:
if(mb_strlen($postcomment) > MINIMO_DE_CARACTERES && !isset($uploaded)){
$passa = true;
}
To find out if you start with http
you can use REGEX, just remember that URLs can, start with http
and https
, so you can use:
/^(http|https):\/\//
Logo:
if(preg_match('/^(http|https):\/\//', $uploaded) && !isset($postcomment)){
$passa = true;
}
You do not say what should happen if both are filled, this is a situation that should be dealt with, this would be a solution:
if((!empty($postcomment) ^ !empty($uploaded))
&& (mb_strlen($postcomment) > 20 || preg_match('/^(http|https):\/\//', $uploaded))){
$passa = true;
}
Try this here.
The use of xor
( ^
) will only cause $uploaded
or $postcomment
to be filled, but not both, in this case if both are filled "will not continue".