3

I have a variable that calls an item, but what I have to display is the description of his category. So the structure I figured out is something like this willing that writing $item1 in $var1 it displays "Bla Bla Bla" (the value of $cat1):

$var1 = $item1;
$item1 = $cat1;
$cat1 = 'Bla Bla Bla';

Believe or not it doesn't work :-) I am a novice with php, sorry to ask stupid questions! And thank you so much to help!

10
  • Hi, not sure exectly what you are trying to achieve Commented Mar 28, 2019 at 22:11
  • are you maybe trying something like $var1->cat1 ? just guessing here Commented Mar 28, 2019 at 22:13
  • Yes and my english does not help (I am Italian)... indeed I would like to write <?php echo $var1; ?> in my page and display "Bla Bla Bla" but I need to use those 3 variables Commented Mar 28, 2019 at 22:14
  • why do you need 3 variables ? Commented Mar 28, 2019 at 22:15
  • Because it is the product, the category and the family... so when I set the product I need also to display the Family Description Commented Mar 28, 2019 at 22:16

1 Answer 1

4

assignation of values in most common programm languajes is up to down (cascade programming style)

$var1 = $item1;  <--- at this point $item1 is "empty" or null
$item1 = $cat1;  <--- at this point $cat1 is empty too
$cat1 = 'Bla Bla Bla';  <--- here $cat1 take value 'Bla Bla Bla' 

so, you have to invert order of assignation like this:

$cat1 = 'Bla Bla Bla';
$item1 = $cat1;
$var1 = $item1;

the output show 'Bla Bla Bla' for $cat1 $item1 and $var1 hope this help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.