- ctype_digit: documentation ( source)
<?php
$_GET['week_of']=20151111;
if(!isset($_GET['week_of'][8])&&ctype_digit($_GET['week_of'])&&
(DateTime::createFromFormat('Ymd',$_GET['week_of'])->format('N')===1)
){
$week_of=DateTime::createFromFormat('Ymd',$_GET['week_of'])->format('Y-m-d');
}elseif(((new DateTime())->format('N'))==1){
$week_of=new DateTime('this monday');
}else{
$week_of=new DateTime('last monday');
}
echo $week_of;