Php 如何正确调用类/控制器中的任何数学相关函数?
我尝试在类/控制器中的一个函数中使用阶乘php内置函数Php 如何正确调用类/控制器中的任何数学相关函数?,php,laravel,laravel-5,Php,Laravel,Laravel 5,我尝试在类/控制器中的一个函数中使用阶乘php内置函数gmp\u fact() 我不断得到: 调用未定义的函数App\Http\Controllers\gmp\u fact() 有人知道为什么吗?或者我该如何修复它 为什么我可以使用其他功能,如strlen、stru split等等 我需要包括任何类型的数学库或什么吗 我的控制器 <?php namespace App\Http\Controllers; use View, Input, Redirect; class CodeCon
gmp\u fact()
我不断得到:
调用未定义的函数App\Http\Controllers\gmp\u fact()
有人知道为什么吗?或者我该如何修复它
为什么我可以使用其他功能,如strlen、stru split等等
我需要包括任何类型的数学库或什么吗
我的控制器
<?php
namespace App\Http\Controllers;
use View, Input, Redirect;
class CodeController extends Controller {
public function getFactorial($num)
{
$fact = 1;
for($i = 1; $i <= $num ;$i++)
$fact = $fact * $i;
return $fact;
}
public function codingPuzzle()
{
return View::make('codes.puzzle');
}
public function codingPuzzleProcess()
{
$word = strtoupper(Input::get('word'));
$length = strlen($word);
$max_value = ($length * 26);
$characters = str_split($word);
$num = 1 ;
$index = 1;
sort($characters);
//dd($characters);
foreach ( $characters as $character) {
$num += gmp_fact($index) * $index;
$index ++;
}
return Redirect::to('/coding-puzzle')
->with('word', $word )
->with('num', $num )
->with('success','Submit successfully!');
}
}
全局函数是隐式查找的。因此,这表明您的PHP设置没有启用GMP模块。如何启用它?我应该通过php.ini
启用它还是以编程方式包含它?可能需要在php.ini
中启用安装GMP的副本。搜索php_gmp.dll并确保它没有被注释掉。如果需要,请取消对其注释并重新启动Web服务器。将隐式查找全局函数。因此,这表明您的PHP设置没有启用GMP模块。如何启用它?我应该通过php.ini
启用它还是以编程方式包含它?可能需要在php.ini
中启用安装GMP的副本。搜索php_gmp.dll并确保它没有被注释掉。如果需要,请取消对其注释并重新启动Web服务器。