codeigniter get value from url










3














How can i recieve the value in a controller from the following URL in codeigniter



http://localhost/directory/c_service/get_radius/lang=123


controller:



class C_service extends CI_Controller {
function __construct()

parent::__construct();


public function get_radius()


i need to get the vLUE 123 here
like,
`$value=$get['lang'];`




Thanks










share|improve this question























  • what is your controller name? and What value do you intend to receive?
    – DhruvPathak
    Mar 12 '12 at 11:49










  • sorry,my controller name is "c_service" and "get_radius" is a function in controller..i need to recieve the value 123 inside the function "get_radius"
    – youv
    Mar 12 '12 at 11:53










  • No need to -1 this question.
    – StackOverflowed
    Oct 19 '12 at 3:27















3














How can i recieve the value in a controller from the following URL in codeigniter



http://localhost/directory/c_service/get_radius/lang=123


controller:



class C_service extends CI_Controller {
function __construct()

parent::__construct();


public function get_radius()


i need to get the vLUE 123 here
like,
`$value=$get['lang'];`




Thanks










share|improve this question























  • what is your controller name? and What value do you intend to receive?
    – DhruvPathak
    Mar 12 '12 at 11:49










  • sorry,my controller name is "c_service" and "get_radius" is a function in controller..i need to recieve the value 123 inside the function "get_radius"
    – youv
    Mar 12 '12 at 11:53










  • No need to -1 this question.
    – StackOverflowed
    Oct 19 '12 at 3:27













3












3








3


2





How can i recieve the value in a controller from the following URL in codeigniter



http://localhost/directory/c_service/get_radius/lang=123


controller:



class C_service extends CI_Controller {
function __construct()

parent::__construct();


public function get_radius()


i need to get the vLUE 123 here
like,
`$value=$get['lang'];`




Thanks










share|improve this question















How can i recieve the value in a controller from the following URL in codeigniter



http://localhost/directory/c_service/get_radius/lang=123


controller:



class C_service extends CI_Controller {
function __construct()

parent::__construct();


public function get_radius()


i need to get the vLUE 123 here
like,
`$value=$get['lang'];`




Thanks







codeigniter url






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 12 '12 at 11:56

























asked Mar 12 '12 at 11:46









youv

35117




35117











  • what is your controller name? and What value do you intend to receive?
    – DhruvPathak
    Mar 12 '12 at 11:49










  • sorry,my controller name is "c_service" and "get_radius" is a function in controller..i need to recieve the value 123 inside the function "get_radius"
    – youv
    Mar 12 '12 at 11:53










  • No need to -1 this question.
    – StackOverflowed
    Oct 19 '12 at 3:27
















  • what is your controller name? and What value do you intend to receive?
    – DhruvPathak
    Mar 12 '12 at 11:49










  • sorry,my controller name is "c_service" and "get_radius" is a function in controller..i need to recieve the value 123 inside the function "get_radius"
    – youv
    Mar 12 '12 at 11:53










  • No need to -1 this question.
    – StackOverflowed
    Oct 19 '12 at 3:27















what is your controller name? and What value do you intend to receive?
– DhruvPathak
Mar 12 '12 at 11:49




what is your controller name? and What value do you intend to receive?
– DhruvPathak
Mar 12 '12 at 11:49












sorry,my controller name is "c_service" and "get_radius" is a function in controller..i need to recieve the value 123 inside the function "get_radius"
– youv
Mar 12 '12 at 11:53




sorry,my controller name is "c_service" and "get_radius" is a function in controller..i need to recieve the value 123 inside the function "get_radius"
– youv
Mar 12 '12 at 11:53












No need to -1 this question.
– StackOverflowed
Oct 19 '12 at 3:27




No need to -1 this question.
– StackOverflowed
Oct 19 '12 at 3:27












4 Answers
4






active

oldest

votes


















6














In Codeigniter you can simply do



public function get_radius($lang)

var_dump($lang); //will output "lang=123"



So your link could be simplified to http://localhost/directory/c_service/get_radius/123 if you don't want to do something like explode('=', $lang) to get your value.



You should however also consider adding a default value public function get_radius($lang=0) if the link is opened without a parameter.



Adding more variables is as easy as public function get_radius($lang, $other) for http://localhost/directory/c_service/get_radius/123/other






share|improve this answer




























    15














    You can use:



    <?php
    $this->input->get('lang', TRUE);
    ?>


    The TRUE is to turn on XSS filtering, which you do want turned on.



    Check out https://www.codeigniter.com/user_guide/libraries/input.html for more info.






    share|improve this answer






























      9














      enable url helper in config/autoload.php



      $autoload['helper'] = array('url');


      or load url helper in desired controller or its method



      $this->load->helper('url');


      and then use below in controller



      $this->uri->segment(3);


      the above line will get you the first parameter, increasing value will get you parameters



      $this->uri->segment(4);


      will get you second and so on.



      hope this helps you






      share|improve this answer




























        3














        I manage it and i check it thats working
        first load the url



        $this->load->helper('url');
        $this->uri->segment(3);


        example : http://localhost/schoolmanagement/student/studentviewlist/541



        if you use $this->uri->segment(3); you get (541) id



        The above line will get you the first parameter, increasing value will get you parameters



        $this->uri->segment(4);





        share|improve this answer






















          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9666433%2fcodeigniter-get-value-from-url%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          In Codeigniter you can simply do



          public function get_radius($lang)

          var_dump($lang); //will output "lang=123"



          So your link could be simplified to http://localhost/directory/c_service/get_radius/123 if you don't want to do something like explode('=', $lang) to get your value.



          You should however also consider adding a default value public function get_radius($lang=0) if the link is opened without a parameter.



          Adding more variables is as easy as public function get_radius($lang, $other) for http://localhost/directory/c_service/get_radius/123/other






          share|improve this answer

























            6














            In Codeigniter you can simply do



            public function get_radius($lang)

            var_dump($lang); //will output "lang=123"



            So your link could be simplified to http://localhost/directory/c_service/get_radius/123 if you don't want to do something like explode('=', $lang) to get your value.



            You should however also consider adding a default value public function get_radius($lang=0) if the link is opened without a parameter.



            Adding more variables is as easy as public function get_radius($lang, $other) for http://localhost/directory/c_service/get_radius/123/other






            share|improve this answer























              6












              6








              6






              In Codeigniter you can simply do



              public function get_radius($lang)

              var_dump($lang); //will output "lang=123"



              So your link could be simplified to http://localhost/directory/c_service/get_radius/123 if you don't want to do something like explode('=', $lang) to get your value.



              You should however also consider adding a default value public function get_radius($lang=0) if the link is opened without a parameter.



              Adding more variables is as easy as public function get_radius($lang, $other) for http://localhost/directory/c_service/get_radius/123/other






              share|improve this answer












              In Codeigniter you can simply do



              public function get_radius($lang)

              var_dump($lang); //will output "lang=123"



              So your link could be simplified to http://localhost/directory/c_service/get_radius/123 if you don't want to do something like explode('=', $lang) to get your value.



              You should however also consider adding a default value public function get_radius($lang=0) if the link is opened without a parameter.



              Adding more variables is as easy as public function get_radius($lang, $other) for http://localhost/directory/c_service/get_radius/123/other







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 12 '12 at 12:27









              danneth

              2,11311628




              2,11311628























                  15














                  You can use:



                  <?php
                  $this->input->get('lang', TRUE);
                  ?>


                  The TRUE is to turn on XSS filtering, which you do want turned on.



                  Check out https://www.codeigniter.com/user_guide/libraries/input.html for more info.






                  share|improve this answer



























                    15














                    You can use:



                    <?php
                    $this->input->get('lang', TRUE);
                    ?>


                    The TRUE is to turn on XSS filtering, which you do want turned on.



                    Check out https://www.codeigniter.com/user_guide/libraries/input.html for more info.






                    share|improve this answer

























                      15












                      15








                      15






                      You can use:



                      <?php
                      $this->input->get('lang', TRUE);
                      ?>


                      The TRUE is to turn on XSS filtering, which you do want turned on.



                      Check out https://www.codeigniter.com/user_guide/libraries/input.html for more info.






                      share|improve this answer














                      You can use:



                      <?php
                      $this->input->get('lang', TRUE);
                      ?>


                      The TRUE is to turn on XSS filtering, which you do want turned on.



                      Check out https://www.codeigniter.com/user_guide/libraries/input.html for more info.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 12 at 10:07









                      Manu K M

                      531314




                      531314










                      answered Mar 12 '12 at 11:53









                      Robert Stanley

                      2,32911220




                      2,32911220





















                          9














                          enable url helper in config/autoload.php



                          $autoload['helper'] = array('url');


                          or load url helper in desired controller or its method



                          $this->load->helper('url');


                          and then use below in controller



                          $this->uri->segment(3);


                          the above line will get you the first parameter, increasing value will get you parameters



                          $this->uri->segment(4);


                          will get you second and so on.



                          hope this helps you






                          share|improve this answer

























                            9














                            enable url helper in config/autoload.php



                            $autoload['helper'] = array('url');


                            or load url helper in desired controller or its method



                            $this->load->helper('url');


                            and then use below in controller



                            $this->uri->segment(3);


                            the above line will get you the first parameter, increasing value will get you parameters



                            $this->uri->segment(4);


                            will get you second and so on.



                            hope this helps you






                            share|improve this answer























                              9












                              9








                              9






                              enable url helper in config/autoload.php



                              $autoload['helper'] = array('url');


                              or load url helper in desired controller or its method



                              $this->load->helper('url');


                              and then use below in controller



                              $this->uri->segment(3);


                              the above line will get you the first parameter, increasing value will get you parameters



                              $this->uri->segment(4);


                              will get you second and so on.



                              hope this helps you






                              share|improve this answer












                              enable url helper in config/autoload.php



                              $autoload['helper'] = array('url');


                              or load url helper in desired controller or its method



                              $this->load->helper('url');


                              and then use below in controller



                              $this->uri->segment(3);


                              the above line will get you the first parameter, increasing value will get you parameters



                              $this->uri->segment(4);


                              will get you second and so on.



                              hope this helps you







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 12 '12 at 11:54









                              Junaid

                              1,71311430




                              1,71311430





















                                  3














                                  I manage it and i check it thats working
                                  first load the url



                                  $this->load->helper('url');
                                  $this->uri->segment(3);


                                  example : http://localhost/schoolmanagement/student/studentviewlist/541



                                  if you use $this->uri->segment(3); you get (541) id



                                  The above line will get you the first parameter, increasing value will get you parameters



                                  $this->uri->segment(4);





                                  share|improve this answer



























                                    3














                                    I manage it and i check it thats working
                                    first load the url



                                    $this->load->helper('url');
                                    $this->uri->segment(3);


                                    example : http://localhost/schoolmanagement/student/studentviewlist/541



                                    if you use $this->uri->segment(3); you get (541) id



                                    The above line will get you the first parameter, increasing value will get you parameters



                                    $this->uri->segment(4);





                                    share|improve this answer

























                                      3












                                      3








                                      3






                                      I manage it and i check it thats working
                                      first load the url



                                      $this->load->helper('url');
                                      $this->uri->segment(3);


                                      example : http://localhost/schoolmanagement/student/studentviewlist/541



                                      if you use $this->uri->segment(3); you get (541) id



                                      The above line will get you the first parameter, increasing value will get you parameters



                                      $this->uri->segment(4);





                                      share|improve this answer














                                      I manage it and i check it thats working
                                      first load the url



                                      $this->load->helper('url');
                                      $this->uri->segment(3);


                                      example : http://localhost/schoolmanagement/student/studentviewlist/541



                                      if you use $this->uri->segment(3); you get (541) id



                                      The above line will get you the first parameter, increasing value will get you parameters



                                      $this->uri->segment(4);






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Oct 17 '16 at 10:37









                                      SHAZ

                                      2,34661727




                                      2,34661727










                                      answered May 4 '15 at 10:40









                                      Md.Jewel Mia

                                      1,5041316




                                      1,5041316



























                                          draft saved

                                          draft discarded
















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid


                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.

                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid


                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.

                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9666433%2fcodeigniter-get-value-from-url%23new-answer', 'question_page');

                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          這個網誌中的熱門文章

                                          How to read a connectionString WITH PROVIDER in .NET Core?

                                          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

                                          Museum of Modern and Contemporary Art of Trento and Rovereto