Jump to content

Undefined function ctype_digit


Recommended Posts

Ok, this is awkward.  I compiled my version of 5.4.6 on this test partition, and hadn't had any errors until a few minutes ago when I came across this error.  Now, according to the manual, you've had to explicitly --disable-ctype since like... 4.3.  Also, according to the docs, there is no runtime config setting for this. 

 

So... dufuq? and how do i fix it?

Link to comment
Share on other sites

Actually, I think the problem lies with the PHP CLI parser, and not namespaces.

I noticed that you took the phpinfo () dump from a web page, and thus went via the browser (and by extension the CGI executable). Then tried running the code via the CLI executable, and getting the error. I Just did something similar, with json_encode ():

php > var_dump (json_encode ($test));
PHP Fatal error:  Call to undefined function json_encode() in php shell code on line 1

 

However, when I saved it to a file, and ran it via the web server, everything worked just fine. So check what phpinfo () states for the CLI version, and I think you'll be enlightened.

Link to comment
Share on other sites

I quite think you're onto something, @CF.  I ran a dumped a test.php file and there's zero mention of ctype being in there. Now, as seeing as the browser version told me it was enabled, I'm not sure if it was disabled would there be an entry stating thusly or not.  Here's a bit of cli

 

mahngiel@studio46 ~ $ php test.php > output.txt
mahngiel@studio46 ~ $ cat output.txt | grep 'ctype'
mahngiel@studio46 ~ $ cat output.txt 
phpinfo()
PHP Version => 5.4.6

System => Linux studio46 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64
Build Date => Aug 29 2012 15:37:55
Configure Command =>  './configure'  '--disable-debug' '--enable-inline-optimization' '--disable-all' '--enable-hash' '--with-pear' '--with-apxs2=/home/apache2.4/bin/apxs' '--with-layout=GNU' '--enable-filter' '--with-pcre-regex' '--with-zlib' '--enable-xmlwriter' '--with-openssl' '--enable-pdo' '--with-pdo-sqlite' '--with-readline' '--with-sqlite3' '--with-iconv' '--disable-phar' '--with-libedit' '--enable-exif' '--with-bz2' '--with-gettext' '--with-mcrypt' '--with-mhash' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-zlib-dir' '--with-xsl' '--with-tidy' '--with-freetype-dir' '--enable-gd-native-ttf' '--enable-mbstring' '--enable-sockets' '--enable-dom' '--enable-xml' '--enable-soap' '--enable-libxml' '--enable-session' '--enable-simplexml' '--with-kerberos' '--with-curl' '--with-mysql-sock' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-config-file-path=/home/php5.4'

 

Now, at this point I'm not sure if I need to recompile or what.  That function is pretty important to my cron jobs, so I've temporarily replaced ctype_digit() with is_numeric()

 

What should I do at this point?

Link to comment
Share on other sites

It's this part that's messing up for you:

'--disable-all'

 

So if you really need the ctype functions, you have a few options available:

  • Recompile PHP-CLI, with --enable-ctype in addition to the flags listed above.
  • Write your own validation functions, and use them instead.
  • Run the script via the local web-server.

Last option being a lazy hack, but.. :P

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.