Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: My first PHP

  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    My first PHP

    Hello everyone,

    last couple of days i have started learning PHP and made my first code.
    Following in the coding

    <html>
    <head>
    <title>My first PHP script </title>
    </head>
    <body>

    <?php
    //This scrip will print a line on page
    echo"Hello world this is my first php script";
    ?>
    </body>
    </html>


    and when i debug it i get the error

    syntax error, unexpected '!' in D:\xampp\php\php.exe on line 1

    Please help me

  • #2
    Banned
    Join Date
    Oct 2012
    Posts
    81
    Thanks
    0
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by wonderwall View Post
    and when i debug it i get the error

    syntax error, unexpected '!' in D:\xampp\php\php.exe on line 1

    Please help me
    in php.exe???

    The file your code is in should have a .php extension in the name. It works fine when copied to index.php on my xampp server.

  • Users who have thanked minder for this post:

    wonderwall (11-23-2012)

  • #3
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    913
    Thanks
    76
    Thanked 28 Times in 28 Posts
    Yup just make sure it has a .php extension and it should work.

    Also if you are learning make sure to visit http://php.net.

    to note, if you're just starting out take a look at some of the String and Array functions and maybe play about with them. I am learning PHP and I always just create random stuff and play about with the functions to see what the result is. Due to doing this I have managed to implement certain codes to my actual site. I find it really cool to use the return value of one function as a parameter for another function.

    Kind regards,

    LC.
    Last edited by LearningCoder; 11-20-2012 at 02:20 PM.

  • Users who have thanked LearningCoder for this post:

    wonderwall (11-23-2012)

  • #4
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for your replies.

    Actually the file name is first.php, what mentioned "php.exe" in the error is something else. Any other suggestion would be appreciated.

  • #5
    Regular Coder Mooseman's Avatar
    Join Date
    Sep 2010
    Posts
    123
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by wonderwall View Post
    Actually the file name is first.php, what mentioned "php.exe" in the error is something else.
    Run the PHP code on a server. Your local PHP configuration is incorrect, and is accessing the D:/ drive, which I would assume is a disc drive.

  • #6
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hello,

    I was using XAMPP to host a local server on my D drive. Is it enough?

  • #7
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    The file at "D:\xampp\php\php.exe" must be related to your PHP configuration. Check the syntax on line 1 in that file.

  • #8
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by wonderwall View Post
    hello,

    I was using XAMPP to host a local server on my D drive. Is it enough?
    Yeah, you can run XAMPP from any drive. You are running the first.php file in the browser, correct? Usually you browse your XAMPP site by going to http://localhost/ but you can set to to another host in your httpd.conf if you have it added to your hosts file as well. Also, if you can't get XAMPP working properly you can try WAMPServer instead, which is essentially the same thing.

  • #9
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    XAMPP is working fine and i am able to see the result of my program when i open the link "http://localhost/first.php". no error in the browser when i ran the program. btw the error is coming when i debug the program in php designer8.

  • #10
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Actually i am debugging the script in php designer8 evaluation version. the output comes fine when i open the scrip in the browser after running the script but first it gives me the above error. btw i removed the evaluation version and installed a complete version and i dont get the error anymore i dont think it was related to php designer?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •