|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Get Url
i have something like this:
PHP Code:
is there some function like get url or something? i want to change the print " ... " to like GOTO abc.php what function do i need to use? and sorry, but as you can see i dont know mutch about php... greetz roberto |
|
#2
|
|||
|
|||
|
PHP isn't a HTML replacement. You will still need to use HTML (or other technologies) for formatting your output.
To display a link: echo "<a href='abc.php'>This is a link</a>"; I'm not sure if that's what you wanted to know?
__________________
Best Regards, Håvard Lindset |
|
#3
|
|||
|
|||
|
RE: RE:
no, not realy...
what i ment is something like this (i know its not the correct php scripting ;-) If $somevar = false goto=somepage.php so, when $somevar is false, redirect to somepage.php |
|
#5
|
|||
|
|||
|
what you could do is see if $somevar has been populated... if not, then it could redirect to another page.....
PHP Code:
So if $somevar had nothing in it, it would redirect to somepage.php... but if it was set to something... eg if the page was called with "somecript.php?somevar=x" then it would redirect to someotherpage.php Or like your first example, you could do: PHP Code:
So the page would redirect ONLY if $somevar was set to "false". eg: somescript.php?somevar=false so if it was somescript.php?somevar=falseeee it wouldn't work... Did you want to get the URL as well? Cos there are some PHP functions to do that............ what is it you need to get? |
|
#6
|
|||
|
|||
|
Hey fakker,
On your first code block there, I think you meant to do this -> PHP Code:
Also, your second code block is dangerous -> PHP Code:
|
|
#7
|
|||
|
|||
|
good job jpenn
![]() |
|
#8
|
|||
|
|||
|
lol.... I think isempty might be an ASP function anyway?!!!
Cheers for the pointers! Matt. |
|
#9
|
|||
|
|||
|
isempty is a vbscript function. asp is not a programming language, just a set of objects.
empty(); is a php function. if (!empty($myVar)) { do something } You CAN use header() to send a raw header and redirect, but this will only work if you have not sent any output whatsoever to the browser, not even a DTD or <html> tag. The best way to accomplish this is just to print a meta refresh line PHP Code:
That will redirect them to somepage.php after 3 seconds. That's how the login redirect is accomplished on this site as well as many others, and it can be used for a good bit of stuffs hope this helps |
|
#10
|
|||
|
|||
|
jpenn
"Also, your second code block is dangerous ->
PHP:-------------------------------------------------------------------------------- If ($somevar == "false") { header ('Location: somepage.php'); } /* Never use comparison '==' or '!=' on (bool) true or false. This can be accomplished by simply using the code below. */ if ( $somevar ) // Will return true if $somevar is set or (bool) true if ( !$somevar ) // Will return false if $somevar is (bool) false -------------------------------------------------------------------------------- " Why is this dangerous? You can evaluate boolean values with == != if you want, just don't put true/false inside quotes. putting them in quotes treats them as a string. which will still yeild the same results so long as you don't put bad data in your variable at some point. It is best practice to evaluate them as you said, but using == or != is not problematic. |
|
#11
|
|||
|
|||
|
Quote:
Well, no. What if he is checking against an integer of '0', but first first wants to check if the string is true, or set, it won't work as '0' will return false. Also, for backwards compatibility, comparison against (bool) true or false by means of comparison operators will not work at all in pre 4 versions.... ![]() |
|
#12
|
|||
|
|||
|
Hm yes good point about previous versions
![]() I was under the impression he was setting the variable to true or false, not checking to see if it contains a non zero non null value. my bad ![]() |
|
#13
|
|||
|
|||
|
No problem. Ive just seen many many posts on my home forum where people are having problems with thier applications, and most of the time it all comes down to bad coding practices. You will probably see alot of my posts correcting coding practices, but of course, no offense to anyone. I am just really keen on writing and running clean and efficient code within the general rules of PHP application development, makes it easier to understand also....
![]() Chow - |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Get Url |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|