douyan2821 2015-01-21 19:52
浏览 53
已采纳

调用未定义的函数is_bool()

My dev server is currently running PHP 5.3.29. When trying to run the is_bool() function on a variable, I receive the error:

Fatal error: Call to undefined function is_​bool() in...

Running echo function_exists("is_bool"); returns true.

Running the commands on my local machine with 5.3.28 yield the same results, but works correctly on my coworker's local machine running 5.5.14.

Although the official PHP documentation says that this function is available in PHP 4 and 5, is there an issue with my PHP versions preventing me from using this function? This is also happening with is_int(), is_null(), etc.

<?php

$Value = "random";  // Also tried integers and booleans

echo function_exists("is_bool");  // prints 1

echo is_​bool($Value) ? "true" : "false";  // Fatal error
  • 写回答

1条回答 默认 最新

  • douduan5086 2015-01-21 20:28
    关注

    I was about to copy&paste your code snippet from above into http://3v4l.org/ to prove you wrong ;) – and syntax highlighting there shows, that you have an invisible character between is_ and bool (in the line you marked with the // Fatal error comment).

    Pasting it into Notepad++ and viewing it in Hex mode shows that the byte sequence is e2 80 8b, and that is the UTF8-encoded version of a zero width space character.

    So just re-type it completely (presumably that has gotten in there by copy&pasting it from somewhere, where the output was formatted in some way) – and it should work fine …

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?