Using TextEdit - PHP script not executing properly

Discussion in 'Web Design and Development' started by moonman239, Mar 28, 2014.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I'm trying to write a PHP file in TextEdit.

    I put this in between <?php and ?>:
    Code:
    echo "Hello";
    
    When I ran the script, I got this as output: “Hello”

    If I insert any non-alphanumeric character between those quotation marks, I get an error:
     
  2. theluggage macrumors 68030

    Joined:
    Jul 29, 2011
    #2
    TextEdit has 'helpfully' translated your regular ASCII quote marks (") into proper Unicode open (“) and close (”) quote marks. Looks nicer on paper - totally louses up programming languages.

    TextEdit has evolved (or devolved) into a sort of word processor-lite - don't use it for programming or HTML coding.

    Download a copy of TextWrangler (a free, safe bet) to get started, and should you feel the need for more bells and whistles look elsewhere in this forum for discussions on alternative HTMP/PHP/JavaScript editors and IDEs.
     
  3. Darth.Titan macrumors 68030

    Darth.Titan

    Joined:
    Oct 31, 2007
    Location:
    Austin, TX
    #3
    Make sure in the font menu in TextEdit to select "Make Plain Text".
     
  4. theluggage macrumors 68030

    Joined:
    Jul 29, 2011
    #4
    Nope - even in "plain text" mode, TextEdit will still change "foo" to “foo”.

    You need to go to preferences and turn off smart quotes, smart dashes... and preferably turn off TextEdit. The fact that, by default, TextEdit corrupts source code should be a clue that its not the tool for the job.
     

Share This Page