Questions tagged [php-7]
PHP 7 is the successor to PHP 5.6, it was released on December 3, 2015. Use this tag for issues relating to development using PHP 7
2,754
questions
0
votes
1
answer
42
views
overwriting basic count function in laravel globally
We are upgrading our laravel project, and it includes a language upgrade from php7 to php8. Consider this code:
$a = new stdClass()
count($a)
Will result in:
// php7
==> 1
// php8
==> ...
0
votes
1
answer
46
views
Errors PHP Notice: Undefined offset:, Trying to access array offset on value of type null
I get multiples php errors in server log , the error show on 2 lines of my php code, However php script is working but it show these errors in server log.
PHP Notice: Trying to access array offset on ...
0
votes
1
answer
108
views
Drupal 7 modules appear to be php8 compatible but crashes when server changes from php7.3 to php8.1
Somewhere it said that Drupal 7.8 updated core and modules are php compatible with php8.1.
However, when I change the cpanel multiphpmanager for the Drupal 7 domain to php8.1, the site crashes.
The ...
-1
votes
2
answers
56
views
$_GET not display character like & [duplicate]
i tried to create a script to redirect link of amazon, but when pass the link in a get variable url not return Url after the character &, i tried to echo the variable $_GET['tolink'] but display a ...
0
votes
1
answer
314
views
Why i get alert : "This page has expired" in laravel livewire upon logging back in in?
I created a step-by-step form using Laravel Livewire, following this tutorial: here.
However, I'm experiencing some issues when logging in after logging out, when I submit the form I get a alert:
&...
0
votes
0
answers
84
views
Encryption/Decryption with Sodium extension with php 5.6 not working
My Old project is on 5.6 so Sodium extension for Encryption/Decryption is not working so my system engineer set some setting that if I run file with .php7 extension it run on php 7 and normal .php ...
0
votes
0
answers
283
views
firebase/php-jwt throws Signature verification failed error on every scenario in PHP 7.4
I've installed firebase/php-jwt as described in the repo.
In composer file.
"firebase/php-jwt": "~5.5.1",
"paragonie/sodium_compat" : "~1.19.0",
In my PHP file
...
0
votes
1
answer
29
views
Under the Laravel 7 (php7) system, if I query any id of my table, there is no result
Under the Laravel 7 (php7) system, if I query any id of my table, there is no result, but if I enter the id value as a string, then there is a result.
In the table, the id column type is int(11). ...
0
votes
0
answers
32
views
Replace all matching substring with results of function using those substrings as an argument in PHP?
I have strings like this
you find ^1d6+1 gonkulators and ^1d3 merkel jammers!
I have a function that takes gamer dice notation such as "1d6+1" and "1d3" and computes random ...
1
vote
1
answer
55
views
Cannot access the properties inside the Closure object in php 7
I have this in my unit test code:
$data = $this->_createSfApiFindMock($cisDataCount);
var_dump($data()); die();
output:
class Closure#731 (3) {
public $static =>
array(4) {
'...
0
votes
2
answers
244
views
Prestashop 1.7: Use statement not working in module main php file
I would like to edit the kpi section on the admin orders page,in Prestashop 1.7, so i created a module, i tried to use a custom module class, in the module's main php file, but i got error
so I ...
-1
votes
2
answers
202
views
Laravel ErrorException Undefined variable in my public function
I ran into the error:
ErrorException Undefined variable: pesan
I have gone through similar problems solved here but none of the solutions have worked for me.
The error is thrown from my ...
0
votes
0
answers
77
views
Uncaught ReflectionException: Class App\Http\Kernel does not exist laravel 8
composer.json >>>>
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
&...
2
votes
0
answers
262
views
Errors in PHP 7 - why set_error_handler() can't catch this type of error?
Fatal error: Uncaught TypeError...
Why is this an exception according to PHP if TypeError inherits from Error? Why can't set_error_handler() catch this type of error?
https://www.php.net/manual/en/...
0
votes
1
answer
240
views
ubuntu 18.4: how to get php 7.2 to work with apache 2?
I purchased a virtual server from vpscity, and chose the Ubuntu 18.4 64bit image.
it came with apache 2 installed.
i am trying to get webpagetest server installed using these instructions: https://...
0
votes
0
answers
121
views
Call one controller function from another using Curl PHP in CodeIgniter 3
Hi I am using Curl PHP to callone controller from Another but even after passing CSRF it is giving me 403 error
MAIN controller file
`
<?php
defined('BASEPATH') or exit('No direct script access ...
1
vote
5
answers
278
views
How do I print an array value as a template tag as blank in shorthand, even if it's null?
If I have this in my main php file (eg. my controller)
$debate['title'] = NULL;
And this in my template file (eg. my views file), where I can include PHP with my HTML. Imagine that I'm using a ...
0
votes
1
answer
281
views
phpinfo() changes the status code of nginx response in a weird way
I have a php code that should always end up being "http 500 code" as I have a call to undefined func status_code("OK");
code:
<?
# phpinfo();
echo 'error_log = ' . ini_get('...
0
votes
1
answer
281
views
digital signature in pkcs7 format with base64 encoding PHP
Is any pre-define function in PHP for making signature in pkcs7 format?
I have .pfx certificate with me
0
votes
0
answers
55
views
Bypass auto wiring using services.yml symfony
I have a quick question regarding auto wiring on symfony.
I am currently migrating my symfony 2.8 app to symfony 5.4. I have my BaseManager class which is used by several manager of my application.
...
0
votes
0
answers
22
views
How to conditinally create a field in an array during initialization?
Consider this code:
$foo = [
'x' => 'asdf',
'y' => $bar,
];
What I want is that if $bar is null, then the field 'y' should not even be created. I know that I can create $foo first and ...
0
votes
1
answer
383
views
How to properly flush buffer without error suppression
I found this snippet many years ago, it's always done me well but I found out recently that error_get_last() and any custom error handlers will ignore the @ and still trigger.
The recommended approach ...
0
votes
1
answer
238
views
Apache2 2.4 not executing PHP 7.4 code, module not showing up
I have Apache2 running on a Debian 11 box (x64). It was installed with an Openmediavault ISO, with nginx and PHP 7.4 installed already (for the web UI) I try to install the PHP connector for apache2 (...
0
votes
1
answer
114
views
Update key value in array of objects php
I have an array of objects where the reference is not the same as the code_cip.
Array (
[9921279] => lignecatalogue Object ( [id] => 3013181 [reference] => 9921279 [commentaire] => [...
0
votes
1
answer
40
views
Convert many:many response into single objects
I have defined a users table, a roles table and a user_role pivot in my database. The model for the user is as follows:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ...
-1
votes
1
answer
82
views
PHP exec shell script return status 2
I want to execute shell script from my php application deployed on Red Hat linux server, I added this line to my application
exec("/app/sh/script.sh user server.info.com cmd.com 0 1 1" ,
...
1
vote
2
answers
35
views
Line up two tables
I have two following arrays:
$array1 = [
['date' => '2021', 'income' => 123],
['date' => '2022', 'income' => 123],
['date' => '2023', 'income' ...
1
vote
1
answer
315
views
Composer issues when running mPDF in PHP 7.4
I get the following error when running mPDF in my browser. I have just installed the latest version of mPDF on my cloud server running PHP 7.4. The requirements page for mPDF say I should be able to ...
0
votes
1
answer
20
views
How to use an anonomyous function directly to assign a value? [duplicate]
I know I can do this:
$myFunc = function () { return 42; };
$val = $myFunc();
But I want to skip $myFunc and do something like this:
$val = () { return 42; };
Is this possible?
Of course, my real ...
-1
votes
1
answer
95
views
how to properly load libraries in php? [duplicate]
I'm working with two libraries:
phpdotenv
spatie/async
This is what I'm executing:
<?php
require_once "/var/local/entrop/vendor/autoload.php";
include_once '/var/local/entrop/inc/...
1
vote
1
answer
48
views
How to do covert to this code block to php v7.4 or fix the syntax error
Currently I'm working with a laravel base ecommerce project and I got a domain mapping plugin which they provide. But the problem is it's only working on php8 or 8+, but my application runs on php v7....
1
vote
1
answer
33
views
I have implemented function without using function key but not able to print the result
I have written one function, without using function keyword.
if age is above 15 take the value and push into one array. I have done that but i am not able print the result.Kindly any one help on this.
...
2
votes
0
answers
82
views
PHP 7. I'm not able to display or log errors below. Is this possible? [duplicate]
Example 1
<?php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
// I guess I miss a semicolon
a()
b()
Example 2
<?php
ini_set('display_errors', '...
0
votes
0
answers
48
views
php7 compatibility: Uncaught Exception: Error
can you help me update this script for compatibility with php7? I get error: Uncaught Exception: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ...
0
votes
0
answers
16
views
database connection error message not woking [duplicate]
Please, can I know what's wrong with this function. I want if the connection to database is not established to display a custom error message instead of the default exeption.
<?php
$host = &...
1
vote
0
answers
115
views
PHP, Docker, Apache & EC2 - intermittent POST request failures
I'm getting some very odd behaviour with my app on AWS EC2. Every now and again, when a form is submitted via POST, it'll bomb out straight away displaying the submitted form data. There are no logs ...
0
votes
1
answer
249
views
Sessions not working on CDN but works on localhost
Code works well on localhost, but when i deployed it on hosting that is using CDN,
the PHP session is not working.
On page1, I have form that is using token
<form method='post' action='page2'>
...
0
votes
1
answer
2k
views
Run jobs one after another in Laravel 8
I'm trying to automate a process composed from multiple jobs. Every job had a goal, so I'm running a global job who is responsible for creating child jobs.
- Job-1
Global Job -> - ...
-2
votes
1
answer
91
views
Htmlspecialchars return a mistake value
I'm using PHP 7.4, when I run echo htmlspecialchars("Jours Fériés", ENT_QUOTES); I get an empty string.
when I run echo htmlspecialchars("Jours", ENT_QUOTES); I get "Jours&...
0
votes
1
answer
639
views
Laravel - Passing data from multiple methods from the same controller to a partial view
I have a simple phone book application with a main view, index.blade.php that includes a partial view, contact_list.blade.php.
I only have a single route that refers to my controller, ...
0
votes
1
answer
1k
views
Laravel 8 - htmlspecialchars() expects parameter 1 to be string, object given
I'm trying to access a Controller method from inside my view, but I'm getting this error:
htmlspecialchars() expects parameter 1 to be string, object given (View: D:\Programming\Php\Laravel\Laravel-...
0
votes
2
answers
2k
views
Laravel - PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'vestibulare.app\models\telefone' doesn't exist
I'm new to Laravel.
I'm trying to access some data from within a partial view.
I tried to put my query inside the boot method of AppServiceProvider, but Im getting this error:
PDOException::("...
0
votes
1
answer
73
views
Run phpunit with custom php path
I'm working on Redhat server, I'm going to add unit test (PHPUnit) to an existing application, PHP is installed on custom path /logi/php7211 (I shouldn't change any configuration), when I run the ...
1
vote
1
answer
79
views
Upgrading from PHP 5 to PHP 7.4
I'm upgrading an exsiting application from PHP 5.3 to PHP 7.4
class Cl_Detail_Familles_Produit extends Cl_Form
{
public $ref_annuler = "../coh/list_produit.inc";
.
.
...
1
vote
1
answer
180
views
PHP string without quotes
I'm upgrading an exsiting application from php 5.3 to php 7.
I found this code in the application $this->upload_err = ERR_CORRUPTION;
I didn't found any const whith the name ERR_CORRUPTION
can we ...
-2
votes
1
answer
117
views
FInd Missing number and MIN and MAX Value and find Dublicate values count WITHOUT using PHP inbuild functions.Checked many but no suitable for me [closed]
I am having below array
$inputArray = array(1, 2, 5, 7,2);
Now i want to find MIN and MAX Values.
Second Thing find missing values in this array
Third dublicate number count, How can i acheive ...
0
votes
0
answers
949
views
Installing PHP 7.4 manually (offline) on Linux Red Hat server
I have upgraded from PHP 5.3 to PHP 7.2 and the application is working. now I want to upgrade to PHP7.4, when I run the command
'./configure' '--prefix=/logi/php746' '--bindir=/logi/php746/bin' '--...
0
votes
0
answers
229
views
phpMyAdmin does not respond to clicks
My phpMyAdmin web-interface is loaded properly, login OK, I can see a standard post-login screen with all database names etc., but when I left-click on anything - nothing works. I can't even logout. ...
0
votes
1
answer
318
views
How to manage includes, require and use in this project
In this PHP project without framework, I have this folder structure: Adapter, Class and Models
A php file "index.php" is executed from the root and I have problems handling the model and ...
1
vote
0
answers
34
views
Php script to read files with different formats
I am developing a script in php that receives as a parameter by console the name of a file that can have 2 different formats (XML or csv).
The idea is that it is as scalable as possible, being able to ...