Error when installed Yii2

I’ve install Yii2 framework using composer but get this error in my browser (on localhost): Invalid Configuration – yii\base\InvalidConfigException yii\web\Request::cookieValidationKey must be configured with a secret key. How can I solve this problem? Answer There is this problem with basic app now https://github.com/yiisoft/yii2-app-basic/issues/69 where composer install doesn’t generate this key. You need to add this … Read more

Laravel validate at least one item in a form array

I have a form with a series of numbers in an array: <input type=”number” name=”items[{{ $sku }}]” min=”0″ /> <input type=”number” name=”items[{{ $sku }}]” min=”0″ /> <input type=”number” name=”items[{{ $sku }}]” min=”0″ /> I would like to validate that there is at least one of those input fields that has a value. I tried the … Read more

how to use dom php parser

I’m new to DOM parsing in PHP: I have a HTML file that I’m trying to parse. It has a bunch of DIVs like this: <div id=”interestingbox”> <div id=”interestingdetails” class=”txtnormal”> <div>Content1</div> <div>Content2</div> </div> </div> <div id=”interestingbox”> …… I’m trying to get the contents of the many div boxes using php. How can I use the … Read more

PHP: Simple regular expressions to match length?

I’m creating a registration system that needs to check the name/pass etc. with REGEX (and prefer to), what I’ve got so far is: //Check so numbers aren’t first, such as 00foobar preg_match(‘/^(?!\d)[a-z0-9]+$/iD’,$usrname); //Just simple check preg_match(‘/^[a-zA-Z0-9]+$/’,$psword); But I have to do stupid things in IF statements like: if strlen($psword) > 30 || if (strlen($psword) < … Read more

WebDesign: Header file, but with custom Page titles?

I’ve been using headers to create templates for websites. It’s easy, and very convenient for debugging. I now face the problem of using head BUT with custom page titles. If this is my header.php > <html> <head> <title> My Site : ??? </html> </head> <body> </body> </html> I need ??? to be replaced for every … Read more

Detecting a url using preg_match? without http:// in the string

I was wondering how I could check a string broken into an array against a preg_match to see if it started with www. I already have one that check for http://www. function isValidURL($url) { return preg_match(‘|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i’, $url); } $stringToArray = explode(” “,$_POST[‘text’]); foreach($stringToArray as $key=>$val){ $urlvalid = isValidURL($val); if($urlvalid){ $_SESSION[“messages”][] = “NO URLS ALLOWED!”; header(“Location: … Read more