euphoric Posted August 9, 2010 Report Share Posted August 9, 2010 Labs vakars, visiem ! Palīdziet lūdzu ar `regulāro`. http://www.example.com/controller/class/param1/param2/ . . . Vaig izvilkt `kontrolleri` . Būšu ļoti pateicīgs =) Quote Link to comment Share on other sites More sharing options...
briedis Posted August 9, 2010 Report Share Posted August 9, 2010 explode funkcija. Quote Link to comment Share on other sites More sharing options...
euphoric Posted August 9, 2010 Author Report Share Posted August 9, 2010 Ar, regulāro nekādīgi ? Quote Link to comment Share on other sites More sharing options...
briedis Posted August 9, 2010 Report Share Posted August 9, 2010 (edited) Kam izmantot regulāro, ja nav vajadzības? list($controller, $class, $param1, $param2) = explode("/", "controller/class/param1/param2/"); Edited August 9, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
euphoric Posted August 9, 2010 Author Report Share Posted August 9, 2010 Ar `explode` protu rīkoties :) Pirmā doma bija taisīt ar `regulāro`, sāku domāt kā vaidzētu izskatīties, bet nekādīgi neizdodas, tādēļ arī iepostēju. (Kaut vai tamdēļ, lai nākamreiz prastu/zinātu ;) ) Quote Link to comment Share on other sites More sharing options...
marcis Posted August 9, 2010 Report Share Posted August 9, 2010 $controller = next(explode('/', parse_url('http://www.example.com/controller/class/param1/param2/', PHP_URL_PATH))); Quote Link to comment Share on other sites More sharing options...
euphoric Posted August 9, 2010 Author Report Share Posted August 9, 2010 He,he . Kāda vaina tad : $controller = explode('/', $url); echo $controller[3]; ..vienkāršam variantam ? :) Quote Link to comment Share on other sites More sharing options...
Леший Posted August 10, 2010 Report Share Posted August 10, 2010 Eksplodējot, veidojās masīvs. Tas ir, notiek kkādi [0]=>http:, [1]=>'' utt. Ja tev URLā kāds urķis ierakstīs '.(mysql_query("DROP TABLES")), var arī nostrādāt. Quote Link to comment Share on other sites More sharing options...
101111 Posted August 10, 2010 Report Share Posted August 10, 2010 (edited) Ja izmanto CI (izskatās ka to izmanto), tad vari izmantot $this->router->class Bez tam Code Igniterī vienmēr var izmantot URI klasi http://codeigniter.com/user_guide/libraries/uri.html Edited August 10, 2010 by 101111 Quote Link to comment Share on other sites More sharing options...
euphoric Posted August 10, 2010 Author Report Share Posted August 10, 2010 $this->uri->segments(); Laba fīča, bet manā gadījumā neder, iztikšu ar explode. Pāldies visiem :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.