php-7

PHP Notice: Array to string conversion only on PHP 7

情到浓时终转凉″ 提交于 2020-01-21 06:54:44
问题 I am a newbie of PHP. I study it from php.net , but I found a problem today. class foo { var $bar = 'I am bar.'; } $foo = new foo(); $bar = 'bar'; $baz = array('foo', 'bar', 'baz', 'quux'); echo "{$foo->$bar}\n"; echo "{$foo->$baz[1]}\n"; The documentation(http://php.net/manual/en/language.types.string.php) say that the above example will output: I am bar. I am bar. But I get the different output run on my PC(PHP 7): I am bar. <b>Notice</b>: Array to string conversion in ... on line <b>9</b>

Laravel , how to call a function from another controller

混江龙づ霸主 提交于 2020-01-16 19:41:37
问题 I have a controller with the "getUsers" function in a controller called "UserController" , and inside it I want to call a function of the "CarController" controller called "getCars", the two options I have are: a) Make the second call as "static" , then I can call it without instantiating the class b) Do not do that function of the static class and I call it in this way $ car_id = 100; $ userController = new UserController (); $ userController-> getCars ($ car_id); I do not know which is the

Call to undefined function simplexml_load_file()

夙愿已清 提交于 2020-01-13 10:37:10
问题 I have php 7.0 running on my ubuntu server. php -m command says: [PHP Modules] calendar Core ctype curl date dom exif fileinfo filter ftp gd gettext hash iconv intl json libxml mbstring mcrypt mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML sockets SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zip zlib But still when I run my website, its log says " PHP Fatal error: Call to undefined function

PHP 7 preg_replace PREG_JIT_STACKLIMIT_ERROR with simple string

与世无争的帅哥 提交于 2020-01-11 13:16:07
问题 I know other people have submitted questions around this error, however I can't see how this regex or the subject string could be any simpler. To me this is a bug, but before submitting it to PHP I thought I'd make sure and get help to see if this can be simpler. Here's a small test script showing 2 strings; one with 1024 x's and one with 1023: // 1024 x's $str = '

Difference in matching end of line with PHP regex

℡╲_俬逩灬. 提交于 2020-01-11 09:18:11
问题 Given the code: $my_str = ' Rollo is* My dog* And he\'s very* Lovely* '; preg_match_all('/\S+(?=\*$)/m', $my_str, $end_words); print_r($end_words); In PHP 7.3.2 (XAMPP) I get the unexpected output Array ( [0] => Array ( ) ) Whereas in PHPFiddle, on PHP 7.0.33, I get what I expected: Array ( [0] => Array ( [0] => is [1] => dog [2] => very [3] => Lovely ) ) Can anyone tell me why I'm getting this difference, whether something changed in REGEX behaviour after 7.0.33? 回答1: It seems that in the

PHP7 : install ext-dom issue

馋奶兔 提交于 2020-01-09 00:47:43
问题 I'm running laravel 5.4 on Ubuntu 16.04 server with PHP7. trying to install cviebrock/eloquent-sluggable package throw some error: pish@let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable Do not run Composer as root/super user! See https://getcomposer.org/root for details Using version ^4.2 for cviebrock/eloquent-sluggable ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your

Use private var in declaration of other private var in php

怎甘沉沦 提交于 2020-01-07 12:34:11
问题 Is there a way to use a private variable to declare an other private variable? My Code looks like this: class MyClass{ private $myVar = "someText"; private $myOtherVar = "something" . $this->myVar . "else"; } But this ends in a PHP Fatal error: Constant expression contains invalid operations Tried it with and withoud $this-> Is there a way to do this in php? 回答1: Default values for properties can't be based on other properties at compile-time. However, there are two alternatives. Constant

Storing PHP session.upload_progress data in the database

隐身守侯 提交于 2020-01-06 14:06:17
问题 Using session_set_save_handler in PHP 5.4.40, I have created a session handler that works well ...except for session.upload_progress data when uploading a file. My session handler completely ignores upload progress data, and I can only seem to get the progress data to save at all when: session.save_handler=files; and the session file is saved in the same path as session.save_path Is it possible to save session.upload_progress data in the database? Update : as at PHP 7 this still appears to be

Php artisan serve require fatal error after upgrading php7

陌路散爱 提交于 2020-01-05 05:56:53
问题 After upgrading php from 7.0.14 to 7.0.26 php artisan serve throws this error Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required '/Applications/XAMPP/xamppfiles/htdocs/school-dashboard/public/server.php' (include_path='.:') in Unknown on line 0 回答1: Ok, after hours of pulling my hair out I finally found out what the issue was. In laravel 4 php artisan serve does this under the hood <?php namespace Illuminate