Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

What is -->

Hi, I have a line of code. $key = --> $val

this code code is located in the middle of my script and cueses the interpreter to think this is the end of the code.

My PHP page starts out as <!--php

Please Advise.

3 Answers

A PHP file should begin with <?php. <!-- is an HTML opening comment tag.

A PHP file:

<?php
  $arr = array(
    $key => $val
  );

And HTML file with a comment:

<!-- This is a comment -->
<div>An element</div>

Hello!

You use "=>" in an associative array to assign a value to the key. The extra "--" is either an old php close tag, or a typo you made.

Just try removing the two "-" and you should be ok, assuming all else is correct. Like this:

$array = array(
    '0' => '5',
    '1' => '2',
    '2' => '0',
    '3' => '3',
    '4' => '1');

The Editor i was using was auto commenting my PHP code. I pasted the code from an old program that I was using, so I knew that it worked.

Thanks you both for your help.

I will need to not find a way to upload a PHP file to this server directly.

Thanks Again.