We do a value assignment with the “=” operator, which we learned logically and mathematically in primary school.
This equals event is the same in all current programming languages. This means that in most programming languages of today, value assignment and editing is done with this operator. Because the way of reason is one.
Now let’s assign the newspaper value to the $mail_box variable;
<?php $mail_box = 'newspaper'; echo $mail_box; ?>
The newspaper writes on the screen.
You can specify whether to use quotation marks based on the values you assign to variables. If the value you enter is a number, it is not in quotation marks. But if you’re going to write something, you need to put it in quotes.
<?php $number = 100; $website = 'https://baransel.dev'; $year = 2010; $x = 10; ?>
If you try otherwise and you do not enclose the text in quotes, you will encounter errors. Because everything you don’t put in quotes has to be logical or mathematical.
Changing the value we assign to a variable is the same as loading the first value. So whatever we loaded on that variable last, it carries that value. The codes run from top to bottom.
<?php $mail_box = 'newspaper'; // mail_box variable now has newspaper value $mail_box = 'magazine'; // now has magazine value echo $mail_box; ?>
magazine is written on the screen.
To delete a variable and not use it again, we use the
unset() function. But if you have no idea about the functions, you can save this unset event later.
An exemplary use;
<?php $mail_box = 'newspaper'; unset ($mail_box); // there is no longer a $mail_box variable. ?>