A
A
Andrey Nikolaev2014-02-18 08:38:55
PHP
Andrey Nikolaev, 2014-02-18 08:38:55

PHP: Size in memory of associative array and variables?

There was a conversation about global variables and the question of writing such variables in memory actually ripened.
Suppose we have an associative array:

$aAssoc = array(
 "test" => 1,
 "test1" => "2",
 "test2" => "OK",
);

And variables:
$test = 1;
$test1 = "2";
$test3 = "OK";

Which form of recording will require more memory to work with?
Now I'm not talking about the convenience of work, not about the expediency of using such a number of variables, but about the technical one - memory consumption and speed.
And in addition: what if they are global? Will the consumption or speed of work change? How strong?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
egor_nullptr, 2014-02-18
@gromdron

In short, the array will take more. The globality of variables does not affect memory consumption and performance.

J
Jonh Doe, 2014-02-18
@CodeByZen

Read here habrahabr.ru/post/134784

S
Sergey, 2014-02-18
Protko @Fesor

how arrays are arranged in php

E
evnuh, 2014-02-18
@evnuh

Here is a direct link to a short and precise answer to your question: nikic.github.io/2011/12/12/How-big-are-PHP-arrays-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question