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]
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
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.