php-7.1

Function mcrypt_create_iv() is deprecated within CodeIgniter framework

做~自己de王妃 提交于 2019-12-20 02:35:40
问题 <?php class Encryption { var $skey = "1234561234561234"; // you can change it public function safe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array('+','/','='),array('-','_',''),$data); return $data; } public function safe_b64decode($string) { $data = str_replace(array('-','_'),array('+','/'),$string); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); } public function encode($value){ if(!$value){return false;

Function mcrypt_create_iv() is deprecated within CodeIgniter framework

半城伤御伤魂 提交于 2019-12-20 02:35:10
问题 <?php class Encryption { var $skey = "1234561234561234"; // you can change it public function safe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array('+','/','='),array('-','_',''),$data); return $data; } public function safe_b64decode($string) { $data = str_replace(array('-','_'),array('+','/'),$string); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); } public function encode($value){ if(!$value){return false;

PHP Traversable type hint

给你一囗甜甜゛ 提交于 2019-12-18 18:51:09
问题 I have a relatively simple function which uses a foreach function foo($t) { $result; foreach($t as $val) { $result = dosomething($result, $val); } return $result; } I would like to type hint, and Traversable seems to be the exact type hint I need function foo(Traversable $t) { However this gives a E_RECOVERABLE_ERROR when using an array (which is of course usable in a foreach ): example Argument 1 passed to foo() must implement interface Traversable, array given Is there a way to type hint or

PHP Traversable type hint

Deadly 提交于 2019-12-18 18:49:55
问题 I have a relatively simple function which uses a foreach function foo($t) { $result; foreach($t as $val) { $result = dosomething($result, $val); } return $result; } I would like to type hint, and Traversable seems to be the exact type hint I need function foo(Traversable $t) { However this gives a E_RECOVERABLE_ERROR when using an array (which is of course usable in a foreach ): example Argument 1 passed to foo() must implement interface Traversable, array given Is there a way to type hint or

Preparing for removal of Mcrypt in PHP 7.2

感情迁移 提交于 2019-12-16 20:05:34
问题 So as time moves on mcrypt will go in PHP 7.2. Of course there is an alternative: openssl. I find it difficult to switch from mcrypt to openssl, using AES 256 CBC and preserving IVs. I am sort of new to cryptography, so I don't really know everything, but I understand the basics. Let's say I have the following code function encrypt($masterPassword, $data) { $keySize = mcrypt_get_key_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); $ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);

Testing iterables in PHPUnit

烂漫一生 提交于 2019-12-13 14:36:19
问题 In PHPUnit it quite easy to assert that two arrays contain the same value: $this->assertEquals( [1, 2, 3], [1, 2, 3] ); Recent versions of PHP made usage of Iterators and Generators a lot more attractive, and PHP 7.1 introduced the iterable pseudo-type. That means I can write functions to take and return iterable without binding to the fact I am using a plain old array or using a lazy Generator . How do I assert the return value of functions returning an iterable ? Ideally I could do

Why my middleware is not working,I try to put some parameter inside the middleware and its not working

青春壹個敷衍的年華 提交于 2019-12-12 23:17:18
问题 My middleware should block user with restric_desc = Revoke Student Portal Access. But it end up blocking all user from accessing the tab. Route::group(['middleware' => ['auth'], 'request' =>App\Models\BlockReason::where('IS_ACTIVE','0')->pluck('ID')], function () { Route::group(['middleware' => 'block', 'request' => App\Models\BlockRestricType::where('RESTRIC_DESC', 'Revoke Student Portal Access')->pluck('ID')],function(){ My middleware public function handle($request, Closure $next) { $var=

PhpStorm not finding methods in objects created by late static binding by parent abstract class

随声附和 提交于 2019-12-12 05:26:50
问题 In my PHP application I have a base class for all database objects, which is further extended by specific model classes. It goes on like this (simplified): abstract class Model extends Collection { (...) function __construct(string $primary_key, string $value) { $data = MysqlDB::instance() -> select(static::TABLE, implode(',', static::COLUMNS), "$primary_key=\"$value\""); if (count($data) != 1) throw new ModelException('Select condition uncertain'); parent::__construct($data[0]); } public

Codeigniter 3 email attachment from form

蹲街弑〆低调 提交于 2019-12-12 04:37:29
问题 I have a consultancy controller where users can upload their resume public function consultancy($page = 'consultancy') { if (! file_exists(APPPATH.'views/pages'.$page.'.php')) { show_404(); } $data['title'] = ucfirst($page); $this->load->view('templates/header', $data); $this->load->view('pages/'.$page, $data); $this->load->view('templates/footer', $data); } the view <form enctype="multipart/form-data" style="text-align:left;font-size:12px;" action="<?php echo base_url(); ?>postconEmail/

PHP 7.1: no cURL with HTTP/2

亡梦爱人 提交于 2019-12-12 04:03:29
问题 My question is not about finding out if a server supports HTTP/2 (they both do) but how to make sure PHP is utilizing HTTP/2 with the correct cURL settings for the most current PHP version in CentOS (built from Remi's repository). My own answer addresses some oddities concerning this. I've setup my CentOS 7 server to support HTTP/2 with the help of this fine guide: Setting up HTTP/2 on your web server So I've got the latest releases, compiled and installed them and all is working fine. Pages