URI Segment. |
[eluser]aran384[/eluser]
Was wondering how do I find out what the current URI segment 3 is equal to...? Basically I have a header that gets pulled into different pages, and usuing that header I want to know what the current page is so I can place a bit of code into the header that will relate to the page, FYI, using variables will not work, I have multiple places to place the code, each being different for the different pages.
[eluser]aran384[/eluser]
I was thinking on using the to string bit, but I do not want to use that in case I end up having something like gallery/category/picturename So what ever I use am looking on just taking that first bit.
[eluser]Phil Sturgeon[/eluser]
You can use: Code: if($this->uri->segment(3, '') == 'magoo'): I generally preffer to make use of: Code: $this->uri->router->class; as it means the code is a little more flexible when dealing with sub-directoried controllers.
[eluser]Phil Sturgeon[/eluser]
It will be default return an empty string instead of an error message, always handy. 3 is the third one, 1 will be a sub-directory if you have it or the name of your controller.
[eluser]aran384[/eluser]
kk, how can I add a OR statement to a If statement in PHP? I believe it is something like || or && but couldnt find out on PHP manual how to do it?
[eluser]linuxbz[/eluser]
Do you mean like: Code: if ( $missing or ! $authorized ) The operators you mentioned have a higher precedence: Code: $permitted = $missing || ! $authorized; If you don't know the difference, you probably want to use 'or' or 'and'. See logical operators.
[eluser]aran384[/eluser]
[quote author="linuxbz" date="1182811082"]Do you mean like: Code: if ( $missing or ! $authorized ) The operators you mentioned have a higher precedence: Code: $permitted = $missing || ! $authorized; If you don't know the difference, you probably want to use 'or' or 'and'. See logical operators.[/quote] This is what I was after, it's just I didn't know which PHP used... Whether it was them or other ones. This has been a great help, when I get back onto my computer I will post the code that I used to whether it is right. (Motherboard died so I am missing a computer. |
Welcome Guest, Not a member yet? Register Sign In |