Mümkün güçlü yazılı olması için PHP girdi değişkenleri zorlamak mı

0 Cevap php

PHP ile başladı, ben PHP gevşek yazdığınız ve ne kadar kolay öğrenmek için oldu nasıl gerçekten mutlu oldu. Ben içine büyüdü ama, ben gevşek ziyade onları basitleştirerek benim komut karmaşık aslında yazılmakta olan fark. Ve şimdi ben güçlü benim PHP değişkenleri, özellikle giriş değişkenleri ($_POST, $_GET, $_COOKIE, {[(3)] yazabilirsiniz yollarını arıyorum } ve bazı $_SERVER) vars.

Ayrıca, benim doğrulama ve SQL Injection ve birçok diğer hata eğilimli doğrulama süreçleri hakkında "unutmak" böylece bu süreçte gizlenmiş olması hijyen istiyorum. Ben bu olmak istiyorum nasıl kaba bir taslak var.

Önce değişkeni bildirmek. Tercihen OOP'deki

$varClass->post->variable_name->type('STR', 'SQL', 'EMAIL');  

// or as an array  
$_MY_POST['variable_name'] = array('STR', 'SQL', 'EMIAIL');

Now I could possibly just drop all undeclared variable from the predefined PHP GLOBALs and use the variable type to validate and sanitize them directly in the global arrays.
I could also set the values of unvalidated variables like an emaill to bool false and un-submitted to null and use them during data validation. However, before I went off and re-invented the wheel I was hoping:

some one might direct me to a library which already helps solve my issues?
if there were any reasons why I shouldn't pursue on this wild fantasy? Better and more clear ways of achieving this?
and Other general thoughts you may have about this idea?

0 Cevap