+ 1

Example is wrong?

I am trying this lesson with <?php $name = 'John'; $ age = 25; echo $name; // Outputs 'John' ?> I am typing information similar with the same exact formula but keeps coming out as an error even if I copy and past the example to my own code to see what happens. The script output keeps coming out as unable to be displayed. I've never had this issue before, please fix this lesson/example Sololearn, I am typing it as if it was the same information and no matter whether I copy and paste or type it freshly with my photographic memory as I did before and nothing will help it be displayed the correct way without this error message harassing me.

1st Jan 2018, 1:21 AM
Jacob Givler
Jacob Givler - avatar
8 Respuestas
+ 7
If you have the space between $ and age as shown above, remove it and the code should run. Or just try: <?php $name = 'John'; echo $name; ?>
1st Jan 2018, 1:27 AM
ChaoticDawg
ChaoticDawg - avatar
+ 4
Hard to say what is wrong, show the code you made.
1st Jan 2018, 1:40 AM
Manual
Manual - avatar
+ 2
If the file is pure PHP code then the closing tag ?> isn't required but is optional. If you're mixing your code with HTML then you'll need to close each PHP portion within the file.
1st Jan 2018, 1:47 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
I thank all of you, I am returning to coding after 4 years when I gave it up because I was working part time and in school full-time. I love php, if I didn't why would I be asking so many questions to a great community with lots of potential. I am retaking the course as we speak but I am also taking bits and pieces I need into the try it yourself sessions, memorizing it all over again and am coding from scratch without using the original code the tutorial provided. I am getting better every day. You can say I am an old-timer when it comes to coding but my skills are like that of a novice because I didn't use it so it was very easy to lose it.
1st Jan 2018, 1:50 AM
Jacob Givler
Jacob Givler - avatar
+ 1
Yes they can be as long as needed.
1st Jan 2018, 1:40 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
No errors so far. <?php $name = 'Jacob'; $age = 22; echo $name; // Outputs 'Jacob' ?> Do I have to end the php tag after I finish each part?
1st Jan 2018, 1:43 AM
Jacob Givler
Jacob Givler - avatar
0
You have a space between $ and age
6th Jan 2018, 12:21 AM
mtrelkenty
mtrelkenty - avatar
- 1
Nah, there was no space but I had to adjust it a bit for it to work, can php files be long?
1st Jan 2018, 1:37 AM
Jacob Givler
Jacob Givler - avatar