W
W
wusudewama2016-06-16 14:34:21
PHP
wusudewama, 2016-06-16 14:34:21

Why can a variable contain a different value depending on how it is used?

Hello!
In modx evo, I call the snippet like this:

In the snippet, I have the following code:

var_dump($images);
//string(10) "assets/images/users/c11ab8c3130d794c9c0fbece86402e85.png::||assets/images/users/67f5e9dd2741ccca564d0468352fc8e3.png::||assets/images/users/a0a0ae0d942f01c60fd436555ff8e04c.png::"
var_dump(bin2hex($images));
//string(20) "5b2b696d616765732b5d"
//Эта строка при перекодировании обратно = [+images+]
var_dump(explode('::||', $images));
//array(1) {
//  [0]=> string(10) "assets/images/users/c11ab8c3130d794c9c0fbece86402e85.png::||assets/images/users/67f5e9dd2741ccca564d0468352fc8e3.png::||assets/images/users/a0a0ae0d942f01c60fd436555ff8e04c.png::"
//}

That is, in $images it seems like the string I need, although string(10) makes you think, there are clearly not 10 characters, but in the string "[+images+]" it's like 10.
I want to split it into an array, but explode doesn't work.
And the bin2hex function does not return the value of this line at all, but of the modx placeholder. How does he get there?
Why can this happen? How can I dump the line that var_dump($images) produces?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-06-16
@wusudewama

As I understand it, the $images variable contains a string [+images+]
Just 10 characters long.
All the "excess" that you see is the result of the engine's work on the output.
That is, string(10) "[+images+]"before issuing it to the browser, it converts tostring(10) : "assets/..."

A
Andrew Vakulenko, 2016-06-16
@pro100ShCoder

if you have a TV called 'images' and TV is tied to the template of this page,
then you can call it like this
if TV is taken from a specific page,
then inside the snippet you can get it like this getTemplateVarOutput

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question