Questions about Javascript and PHP

by JakeR
15 replies
I'm in school right now learning C++ and other programming courses in my CIS classes. I"m also a fledgling internet marketer with a strong(focused) plan of attack.

I've read many posts in this section of the forum on PHP but I have heard little about javascript. I'm thinking about coding a website scraper and want to use either php or javascript and I'm not sure which way to go. It seems like most people prefer php above and beyond other languages, but javascript doesn't seem to get much of a mention.

Can anyone clarify why php might be better than javascript and which language would be better to code a website scraper program?

Thanks a lot everyone!
#javascript #php #questions
  • Profile picture of the author shantanu
    PHP is better to understand coz it is quite easy to learn and syntax arenot too complex as javascript. javascript developed by Nowell netware and u have to declare lots of classes and have to check the compatibility of it with oither languages too.
    PHP can be practiced through different IDE's like dreamweaver, artisteer, php designer but javascript cant be practiced on these simple plateforms. It requires netbeans or myeclipse where uhave to declaremany things by urself totally depends on ur knowledge thats why peoples use to say "Learn PHP In 24 Hours" Not Javascript.
    {{ DiscussionBoard.errors[5737429].message }}
  • Profile picture of the author Lovelogic
    Javascript cannot be used to build a complete scraping script due to cross browser security restrictions, somewhere a server has to be used and that typically means PHP, Python or Java will be required.

    The only files javascript can read from another site are XML
    {{ DiscussionBoard.errors[5739624].message }}
    • Profile picture of the author Nochek
      Originally Posted by Lovelogic View Post

      Javascript cannot be used to build a complete scraping script due to cross browser security restrictions, somewhere a server has to be used and that typically means PHP, Python or Java will be required.

      The only files javascript can read from another site are XML

      .jQuery { just call()ed and said 'Can Too!' }
      Signature
      Nochek Solutions Presents:
      The Hydrurga WSO - Rank Your Site #1 And Score Over The Penguin Updates!
      {{ DiscussionBoard.errors[5743249].message }}
  • Profile picture of the author PaybackTony
    Originally Posted by kcartlidge View Post

    By the way, I don't like to criticise other people's answers as they have obviously gone out of their way to try and help, but ignore Shantanu's answer entirely as it is wrong in virtually all respects.

    PHP and Javascript syntax are very similar and, of the two, Javascript is the simpler.

    It was created at Netscape. Novell had nothing to do with it and Netware is one of Novell's products not the name of the company.

    You don't need to declare lots of classes and check compatibility with other languages. If you pull in third party libraries then you may be using classes but that is true of PHP or most other languages. As for compatibility I can only assume it was browser compatibility which was meant in which case that makes a little more sense.

    Javascript does not requires some kind of special IDE, especially not Netbeans or Eclipse. In fact it's easier than PHP in this regard as not only will any text editor suffice (as with PHP) but the debugging facilities are actually built into most browsers.

    There are many books along the lines of "Learn Javascript in 24 Hours" - it is about on a par with PHP at the simplest level, although when you start bringing in libraries it is PHP which adopts a steeper learning curve.

    I have the vague feeling given the mention of Netbeans and Eclipse that there may have been some confusion with Java, which is most definitely not the same thing as Javascript.
    kcartlidge is right. PHP is your only bet of the two. You'll likely be using cURL, or something similar in PHP to pull the content from external sources.

    Since you are studying C++, PHP will come naturally to you (I was a C/C++ programmer before I was a web developer). PHP is very similar in syntax to C++.
    {{ DiscussionBoard.errors[5740376].message }}
  • Profile picture of the author inf
    agreed, you have to think about the two as PHP is serverside and JS is browserside. To build your scraper you will most def want to use PHP
    {{ DiscussionBoard.errors[5750487].message }}
  • Profile picture of the author pseudo
    Great place to know about if you're getting started with PHP
    W3Schools Online Web Tutorials
    {{ DiscussionBoard.errors[5753171].message }}
  • Profile picture of the author Alexis Wilke
    PHP would be the only choice in your case. As mentioned by several people. C++, C#, PHP, JavaScript, and Java are all C like languages that evolved with object oriented capabilities.

    Now if you're studying C++ you may want to consider using that language along with Qt which gives you all the necessary tools to access websites (QNetwork, QDom, etc.) To my point of view PHP does not offer the hardened C++ language checks that the compiler does (i.e. in PHP all variables are variants.)
    {{ DiscussionBoard.errors[5753554].message }}
  • Profile picture of the author phpPro
    read the first response twice and i had doubts if the guy is talking about the same javascript that i work on!!?? but as kcartlidge rightly put it javascript is any day easier than PHP,... higher end javascript yes more comprehension required, .... but then thats true for all languages.

    PHP is the choice if ur doing a scraper,... basically a server language, javascript runs on the browser.
    {{ DiscussionBoard.errors[5756119].message }}
  • Profile picture of the author zon3d
    If you're wanting to learn website design, then learn both PHP and Javascript.
    {{ DiscussionBoard.errors[5757704].message }}
  • Profile picture of the author wordcatcher
    Before you write a web scraping program, it is essential to understand the pattern of the data that you want to extract. You could use any programming language like Java, C#, PHP, PERL, etc. for this processing.
    {{ DiscussionBoard.errors[5790979].message }}
    • Profile picture of the author Earnie Boyd
      Originally Posted by wordcatcher View Post

      Before you write a web scraping program, it is essential to understand the pattern of the data that you want to extract. You could use any programming language like Java, C#, PHP, PERL, etc. for this processing.
      I agree with wordcatcher. And Java, PHP and PERL are interpretive and can be used on any computer where the software that contains the engine be that windows, linux, etc, a server or a client they are all capable of executing your source. You do not need apache or other http daemon to execute PHP, though it is the most used method.
      Signature
      {{ DiscussionBoard.errors[5794663].message }}
  • Profile picture of the author WF99
    mmm... i prefer php:

    i thought and this is what i know
    PHP have mail function
    js, dont have it.
    with php you can have the remote and local time
    with js you can have user time...
    with php you can have remote and host address
    with js ... i dont know !!
    with php the source is not lookable in the source code
    with js the source can be see in the source code of the page.

    That's all, may be i am wrong, but i dont know...
    {{ DiscussionBoard.errors[5901338].message }}
  • Profile picture of the author techiespider
    javascript is client side scripting language and php works on server,,,so you would need both,,,and in javascript use jquery ,,

    [mobile]
    tech
    {india}
    {{ DiscussionBoard.errors[5924658].message }}

Trending Topics