Jump to content

TRUE or FALSE returns from bools


tet3828

Recommended Posts

Quick question.

 

I was reading through some functions in the php manual  ::) I am intrested in using the mkdir function for a project I am working on. The manual says it returns true if it succeeded and a false if it failed.

 

This may be basic and I've prob even done it with other functions but...

 

how can I check the value it returned?

 

so far I have:

 

mkdir ("TRAINING SESSION");

 

so what do I do now?

 

if mkdir == false {return error} ???

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/88995-true-or-false-returns-from-bools/
Share on other sites

You could also assign the function to a variable then test the variable.

 

You can also simply test it as you use it.

 

<?php

  if (mkdir ("TRAINING_SESSION")) {
    echo 'mkdir successfull';
  } else {
    echo 'mkdir failed';
  }

?>

 

ps: Directories (just as files) should not have spaces in there names.

yep, as thorpe suggests mkdir returns true or false.

depending if it succeeded or not.

 

so there is no need to use other functions (is_dir) to check if it succeeeded.

 

since it returns a numeric, ya can use it as an expression (if,while,switch).

 

you will find a lot of functions that return simple information like this, so is of great use.

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.