Jump to content

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.

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.