$ php strposvsstriposvspregbench.php 1
0.40396499633789
0.58028793334961
0.93481206893921
0.91582679748535
$ php strposvsstriposvspregbench.php 100
0.42313885688782
0.50706505775452
4.8115060329437
| /**#@+ | |
| * OLD EVIL METHOD | |
| */ | |
| mysql_connect('localhost', $username, $password) | |
| mysql_select_db('App'); | |
| $userid = mysql_real_escape_string($_GET['userid']); | |
| $query = <<<SQL | |
| SELECT | |
| username | |
| FROM |
| //UNNAMED | |
| $query = "SELECT userid FROM t1 WHERE (username = ? OR useremail = ?) | |
| AND usertoken = ?"; | |
| $prepared_statement = $db_connection->prepare($query); | |
| $prepared_statement->execute(array($_POST['login'], $_POST['login'], | |
| $_POST['token']) | |
| ); | |
| //NAMED | |
| $query = "SELECT userid FROM t1 WHERE (username = :login |
| <?php | |
| class DB extends PDO { | |
| public function __construct($dsn = null, $user = null, $pass = null) { | |
| $dsn = $dsn !== null ? $dsn : "mysql:host=localhost;dbname=$_SERVER[DBNAME]"; | |
| $user = $user !== null ? $user : $_SERVER['DBUSER']; | |
| $pass = $pass !== null ? $pass : $_SERVER['DBPASS']; | |
| parent::__construct($dsn, $user, $pass); | |
| $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| } |
| .final { | |
| /* Basic Styles for the look */ | |
| color: white; | |
| padding: 8px; | |
| cursor: pointer; | |
| font-size: 100%; | |
| font-family: Arial; | |
| /* Old browser background-color */ | |
| background: #0d4e99; |
| function AjaxQueue () { | |
| this.q = []; | |
| } | |
| AjaxQueue.prototype = { | |
| push: function (options) { | |
| options = $.extend({'complete': function () {}}, options); | |
| var originalComplete = options.complete | |
| var qa = this; | |
| options.complete = function () { |
| /* Setup */ | |
| for (var x = 0; x < 5; x++) { | |
| $("<div>").appendTo("body"); | |
| } | |
| $("div").each(function () { | |
| $(this).text((new Array(Math.floor(20 + Math.random() * 4))).join('text ')); | |
| }); | |
| /* Truncation */ |
| <?php | |
| $controller = $container->create($request->controller); | |
| $mediator = $container->create('BeforeMediator'); | |
| $controller->registerMediator($mediator); | |
| $controller->triggerActions(); | |
| $response = $container->create('Response'); | |
| $controller->{'action' . $request->action}($request, $response); |
| <?php | |
| class Mediator { | |
| private $events; | |
| public function attach($event, Callable $callback) { | |
| if (!isset($this->events[$event])) { | |
| $this->events[$events] = array(); | |
| } | |
| $this->events[$event][] = $callback; | |
| } |
| $("input").autocomplete({ | |
| source: $('li').map(function() { | |
| return $(this).text(); | |
| }).get(), | |
| close: function () { | |
| $(this).trigger('blur'); | |
| }, | |
| minLength: 0 | |
| }) | |
| .on('focus', function () { |
$ php strposvsstriposvspregbench.php 1
0.40396499633789
0.58028793334961
0.93481206893921
0.91582679748535
$ php strposvsstriposvspregbench.php 100
0.42313885688782
0.50706505775452
4.8115060329437