Sep 23, 2015

Generate random string with PHP

If you want to generate random code with PHP you can use this function:

<?php
public function genRandmStr($lgt = 8){
       
        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@#!';
        $charactersLength = strlen($characters);
        $randomString = '';
        for ($i = 0; $i < $lgt; $i++) {
            $randomString .= $characters[rand(0, $charactersLength - 1)];
        }
        return $randomString;
    }
}

// you can see the result here
echo genRandmStr();
?>

Sep 18, 2015

CakePHP how to retrieve POST and GET vars

When you are working with CakePHP framework and you try to retrieve the variables which have been sent through GET or POST.

For POST variables you have

For $_POST['key']  we have
$this->request->data('key');


For GET variables you have

For $_GET['kpa']  we have
$this->request->query('kpa');


Sep 8, 2015

HTML5 vs HTML

There is some differences between HTML and HTML5. So though, we have:

HTML5 was designed to replace both HTML 4, XHTML, and the HTML DOM Level 2.
And XHTML is HTML + XML. For a better syntax and for a better administration they had to force HTML to be proper: for instance, if you open this tag <p> you have to close the tag with </p>.

The main goals of HTML5 are:
- Deliver rich content as graphics or movies without the need of additional plugins as Flash, for instance;
- Provide better semantic support for web page structure. For this, HTML5 introduces new structural element tags;
- Provide better cross-platform support (for PC browser, tablet or smartphone);
- Provide a stricter parsing standard to simplify error handling, ensure more consistent cross-browser behavior.

HTML5 has improved the support for embedding graphics, video and audio. For that HTML5 has some new tags: <canvas>, <audio>, <video>

HTML5 has introduced web workers. A web worker is a script that runs in the background, in another thread, without the page has to wait for it to complete. The visitor can continue to interact with the page while the web worker runs in the background.


HTML5 has new semantic tags to complement the structural logic of modern web applications. Here we have:
<main>
<nav>
<article>
<section>
<header>
<footer>
<aside>

HTML5 has new controls like
<calendar>
<date>
<time>
<email>
<url>
<search>



HTML5 has new extensions to the Javascript API as geolocation, drag-and-drop, storage and caching.