PHP & JavaScript Similarities

Discussion in 'Programming' started by gobbly2100, Sep 30, 2007.

  1. #1
    Hey,

    I was just interested in know if there are a lot of jobs that PHP and JavaScript both can cover?

    I am learning JavaScript and know very little PHP but they seem to do the same job in some cases and I just wondered if there is a lot of these similarities.
     
    gobbly2100, Sep 30, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    There are a very few things that both languages can do, but generally you can't even compare them as they're two different things.

    Javascript runs on the client's browser and can't do anything beyond that.

    PHP runs on the server and can handle anything that JavaScript can't. (Databases, user authentication, etc...)
     
    nico_swd, Sep 30, 2007 IP
  3. theOtherOne

    theOtherOne Well-Known Member

    Messages:
    112
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Also, using Javascript makes you dependant on the user's settings, because you are able to disable Javascript in your browser.

    Execution of PHP code only depends on your web server. A user is not allowed to change that ;)

    Furthermore, with Javascript, the actual code is delivered to the user, so he can see how you program. He could also easily steal it. PHP code runs on the server, so what the user sees is not the PHP code, only the generated HTML site (or whatever you like to generate with PHP ;) )
     
    theOtherOne, Oct 1, 2007 IP
  4. Sabbir

    Sabbir Banned

    Messages:
    210
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    No.. exactly very few similarities. even if try to work date() function you will get some touble.
     
    Sabbir, Jan 20, 2008 IP
  5. webexpert

    webexpert Banned

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    there is no any similarities.. because date function returns the date of local computer where php date function returns the date of web server..

    javascript is a client side scripting where php is server side scripting...
     
    webexpert, Jan 20, 2008 IP
  6. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #6
    The programming structure is the same.

    
    if (string == 1) {
        document.write('sting is equal to 1');
    } else {
        document.write('sting does equal to 1');
    }
    
    if ($string == 1) {
        print('string is equal to 1');
    } else {
        print('string does not equal to 1');
    }
    
    Code (markup):
     
    Kaizoku, Feb 3, 2008 IP
  7. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yes, it's different but if you combine them, you'll get a powerful website.
     
    fairuz.ismail, Feb 4, 2008 IP