Jump to content

if else statement with >> functions


smartguyin

Recommended Posts

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]
<?php
function 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]
Link to comment
Share on other sites

What are you trying to do?  Something like this:
[code]<?php
function 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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.