smartguyin Posted January 29, 2007 Share Posted January 29, 2007 CAN I DO SOME THING LIKE THIS...if (!function setup_page($title)) {echo "NO TITLE";}i know this code is worng help me with this to use if else statement Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 take out function and it will work... Quote Link to comment Share on other sites More sharing options...
obsidian Posted January 29, 2007 Share Posted January 29, 2007 Basically, you can do whatever you like as long as your function is set up to return FALSE upon failure. For instance, if I was going to write a function to set my page variables for me based on title, I would do something like this:[code]<?phpfunction setup_page($title) { // Do all your page setup here if (/* something failed */) return false;}?>[/code]That way, you can always set up your function to be able to check your variables:[code]<?php$Page = setup_page($title);if (!$Page) { // Page was not initialized properly}?>[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 29, 2007 Share Posted January 29, 2007 What are you trying to do? Something like this:[code]<?phpfunction setup_page($ttl) { if (strlen($ttl) == 0) return (false);//// do other work// return (true);}if (!setup_page($title)) echo "No Title";else {//// ok//}?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
smartguyin Posted January 29, 2007 Author Share Posted January 29, 2007 still i am not getting it.....i just wanna know if the page is not having [b]setup_page($title)[/b] fucntionthen i wanna echo other thing as i explained above Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 You would use:[code]function_exists('setup_page');[/code]That will return TRUE if the function exists. Quote Link to comment Share on other sites More sharing options...
smartguyin Posted January 29, 2007 Author Share Posted January 29, 2007 can u please explain how to do it coz i have never used tht function before or know how to apply it...please explain Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 You'd want something like this:[code]if (!function_exists('setup_page')) {echo "NO TITLE";}[/code]However, that will only check to see if the function setup page exists. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 This indicates really poor design - your functions should be in a library file, and included on every page, so you don't HAVE to check if you've included the function on that page. Quote Link to comment Share on other sites More sharing options...
smartguyin Posted January 29, 2007 Author Share Posted January 29, 2007 jesi i know its a poor design i am learning it and this is my first project... and will get it done correctly next time..but for now please tell me how can i do tht Quote Link to comment Share on other sites More sharing options...
smartguyin Posted January 29, 2007 Author Share Posted January 29, 2007 but even if (!function_exists('setup_page')) {echo "NO TITLE";}is not working .... its not showing NO TITLE... Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 Then you must have the setup_page function somewhere. Is setup_page in a file that you include() or require()? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 No, that would mean he doesn't have the function on that page. See the ! Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 Oh yes, forgot about that.In that case, remove the !.It's quarter 'til 3 on a Monday, and I haven't had enough caffeine yet. x.x Quote Link to comment Share on other sites More sharing options...
smartguyin Posted January 29, 2007 Author Share Posted January 29, 2007 YES I DON'T HAVE FUNCTION ON THAT ITS ON OTHER PAGE LIKE BODY.PHP WHICH COMES AFTER HEADER.PHPTHE ABOVE CODE IS IN HEADER.PHP SOO IT DOESN'T HAVE THT FUNCTION ON SAME PAGE Quote Link to comment Share on other sites More sharing options...
Balmung-San Posted January 29, 2007 Share Posted January 29, 2007 Does body.php do an include() on header.php?If so, then yes, it will be defined.[url=http://www.php.net/functions]This[/url] page might be useful. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 Don't fucking yell at us. If your problem still isn't fixed, obviously you're not explaining it well enough. Chillax and come back when you can communicate with us. Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted January 29, 2007 Share Posted January 29, 2007 Man I love how inflammatory caps lock is! Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 AYE! Quote Link to comment Share on other sites More sharing options...
smartguyin Posted January 29, 2007 Author Share Posted January 29, 2007 Jesi i am not yelling i mistakely kept the caps on..... if i hurt you i am sorry for those mistakely keeping Caps On.....okay thanks for even trying.... thank you all except jesi... babes i was not Yelling on anyone... and why should i ????????/ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 You really should look at what you've written before hitting that Post button - perhaps more of what you say would make sense if you proofread it. Then you'd catch all the misspellings, words and letters missing, and caps lock. If you actually care about what you're saying, you can take two seconds to say it right. 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.