Posts: 84
Threads: 17
Joined: Mar 2010
2010-05-13, 03:08:57
(This post was last modified: 2010-05-13, 03:20:34 by apelsinas.)
I have a problem with this function in a php guestbook,when i use get_theme_url in the form action (html) the function work correctly but when i use this in php code for receive guestbook.txt directory ($dirfile=get_theme_url()."/guestbook.txt"; ) it doesn't work beacause it prints the url.How i can resolve?
Posts: 1,108
Threads: 70
Joined: Aug 2009
functions beginning with "get_" will echo the result, "return_" functions will return to a variable...
however there is none for theme_url
you could just use
Code:
$dirfile=$SITEURL . "theme/" . $TEMPLATE."/guestbook.txt";
Mike.
Posts: 84
Threads: 17
Joined: Mar 2010
Thank you but there is another problem,if i try to echo $dirfile the file url is ok but when i use the function file_exsists($dirfile) it returns false.Why?If i paste the url of $dirfile on my browser,i should be it...
Posts: 3,491
Threads: 106
Joined: Mar 2010
You could use the constant GSTHEMESPATH:
Mike's example would then be:
Code:
$dirfile=GSTHEMESPATH.$TEMPLATE."/guestbook.txt";
However I would rather store it in the data/other path:
Code:
$dirfile=GSDATAOTHERPATH."/guestbook.txt";
List of GetSimple constants here:
http://get-simple.info/docs/plugin-creation
Posts: 972
Threads: 27
Joined: Aug 2009
Alessio_roma Wrote:When i use the function file_exsists($dirfile) it returns false. Why?
Because file_exists() needs a path to the file on the server, the browser need the URL where it can retrieve the file. The constants Carlos mention are paths on the server, something like "/public_html/data/other/", and $SITEURL as mentioned by Mike will return something like “http://example.ms/â€Â.
I hope you understand the difference
Posts: 84
Threads: 17
Joined: Mar 2010
thank you very much,now it works!