All Questions
88
questions
0
votes
1
answer
2k
views
PHP check if object exists and get it's property in one line
I am wondering if there is in php7.3/php7.4 somehow possible to check inline if and object exists and if yes then get it's property like nullsafe operator. Like this it returns error:
$object = null;
...
-3
votes
2
answers
359
views
How can I remove a private property from an array of object?
$array = $this->em->getRepository($entity)->filter($id);
With doctrine I am creating an array:
array:24 [▼
0 => Members^ {#543 ▼
-id: 1
-username: "lio"
-email: &...
1
vote
2
answers
381
views
Trying to get property 'deskripsi' of non-object (View:
@extends('layouts.admin')
@section('content')
@foreach($galerys as $data)
<form method="post" enctype="multipart/form-data" action="{{url('/ubahGaleryPost')}}">
{...
0
votes
0
answers
46
views
PHP Access Object properties in the Array
In the array, Students objects are stored.
class Student {
//Class definition goes in here.
private $_name = "";
private $_student# = 0;
private $_mojor= ""
}
enter image ...
-3
votes
1
answer
111
views
How can I print/echo/get all attributes from each of the objects in this code?
How can I print/echo all properties/attributes values from all Country objects in this code? I thought of using 'foreach' but I don't know the sintaxis.
The echo statement is in the last line of code....
2
votes
2
answers
2k
views
Accessing nested property on stdClass Object with string representation of the node
Given a variable that holds this string:
$property = 'parent->requestdata->inputs->firstname';
And an object:
$obj->parent->requestdata->inputs->firstname = 'Travis';
How do I ...
0
votes
1
answer
238
views
Why can't the PHP debugger find this object change?
I am trying to track down where a change to a PHP object takes place, and the debugger is unable to step into the code where it happens.
I am tracing through a constructor with three assignments.
...
0
votes
2
answers
623
views
Trying to get property of non-object, but it is an object
I try to get a property of an object.
function page($json, $name) {
$data = json_decode($json);
//$0 = '0';
$cSKU = '574294403';
var_dump($data->variations->$cSKU->...
-1
votes
2
answers
68
views
Use concatenation to write the property name
There is a way to write this?
$request->inputModificaNome.$nomeModel.$i;
where "inputModificaNome" is always the same and $nomeModel and $i are variables.
0
votes
2
answers
118
views
Dynamic assignment of property names based on array values
I am trying to create a class that is going to generate dynamic class properties according to a user input.
There will be an array created from user input data. This array should work as an example:
$...
-1
votes
2
answers
1k
views
Clone PHP object and set protected property on clone
I got a logical problem.
I got an object that needs to be cloned.
The object is|has a result of a calculation.
The object has a runtime.
In some cases it is faster to clone the object instead of ...
0
votes
0
answers
1k
views
PHP Validate properties of object
I want to validate the object properties. Because we do not know PHP OOP more, we chose this way:
First create Validator:
namespace Validator;
/**
* Class ObjectPropertyValidator - Validate object,...
1
vote
2
answers
79
views
Accessing the properties of an object of an object dynamically in PHP
Given that I'm getting different object results depending of the API I query, here are two examples out of 35 I have to implement:
stdClass Object
(
[mid] => 7127.75
[bid] => 7126.6
...
3
votes
1
answer
204
views
Reference an object property with a variable
I need to reference an object property with a variable like this:
$user = User::find( 1 );
$mobile = $user->getData( 'phone.mobile' );
The value of the $data property in the object is a jSON ...
11
votes
5
answers
5k
views
How can I safely retrieve this property of this object?
I have a Stripe subscription object that looks like this...
subscription: {
items: {
data: [
plan: {
id: 'my_plan_id'
}
]
}
}
What's ...