# php74-json not running in apache



## mojo (Mar 9, 2022)

phpinfo states the authors of the extension, yet neither json_decode, nor json_encode work when run on Apache 2.4.
json_encode error:

```
Hello world
Fatal error: Uncaught Error: Call to undefined function json_encode() in /usr/local/www/bleh/jsondecode3.php:9 Stack trace: #0 {main} thrown in /usr/local/www/bleh/jsondecode3.php on line 9
```
json_encode working correct:

```
php jsondecode3.php
PHP Warning:  Module 'json' already loaded in Unknown on line 0
Hello world{"name":"John","age":30,"city":"New York"}
```

json_decode outputs the same generic "call to undefined function", and no - loading the extensions through php.ini or /usr/local/etc/php/ext-20-json.ini ofc does not make any difference.
Anyone else experiences this particular issue? Could it be some licensing issue?


----------



## SirDice (Mar 9, 2022)

Check if you're not accidentally mixing PHP 7.4 and 8.0.


----------



## mojo (Mar 9, 2022)

SirDice said:


> Check if you're not accidentally mixing PHP 7.4 and 8.0.




```
/usr/ports/lang/php80 $ make deinstall && cd ../php81 && make deinstall
===>  Deinstalling for php80
===>   php80 not installed, skipping
===>  Deinstalling for php81
===>   php81 not installed, skipping
```


----------



## anlashok (Mar 9, 2022)

Have you installed the devel/php74-json extension? It's a separate package to the core lang/php74, and isn't in the lang/php74-extensions metaport.


----------



## richardtoohey2 (Mar 9, 2022)

I've got PHP 7.4.28 and Apache 2.4 and json working fine - so you've got something mixed up on your set-up.

If it works from the CLI but not under Apache then you might need to restart Apache (if using mod_php) or restart php-fpm (if you are using FPM).

The warning about module json already loaded suggests you've got it twice in some configuration file (can't remember which one).


----------

