douxun2018 2013-09-13 17:35
浏览 27
已采纳

客户端框架缩小了对php的需求[关闭]

Im looking for some clarification to my understanding of client and server side languages.

I am starting a new project and want to decide if I should implement a client-side framework like angular or ember.

When I started to dig into it, the difference between client side and server side rendering came into question.

My understanding (most likely flawed) is that php becomes quite obsolete because all you need to use it for is communicating with databases and passing json to angular.

PHP's main draw was that you could render html on the server side alongside html, but this no longer is necessary.

With the introduction of client-side frameworks, is PHP still worth using?

  • 写回答

2条回答 默认 最新

  • douzhang3898 2013-09-13 17:56
    关注

    You'd want to use PHP in a few scenarios; note that this list is not exhaustive. It's also worth noting that there are obvious things, like generating the responses for client-side frameworks which I will largely ignore.

    When security is important; If you have something that needs to happen and it can't be tampered with, keep it on the server side. Never trust users.

    When generating page content. Search engines can't afford to execute every script they encounter, so they only parse the raw HTML. If absolutely everything relies on dynamic scripting search engines will not see any of it. Also, your users might not be able to use Javascript.

    When clients have low-end devices Especially with early screenphones or netbooks that don't have huge amounts of horsepower, Javascript can become very intense for these devices very quickly. The more work you offload to the client, the slower the site will be to them. I've seen some java-heavy websites bring the whole device to a crawl. Older browsers without the latest JS engines can be horrifically slow. I have a relatively expensive phone but I've mentally blacklisted several sites because they destroy my device.

    When stability is important. Unless you give PHP fatal errors, you can consider PHP pretty reliable compared to Javascript. If a page works for one person you know other people will get those pages. With Javascript, some browsers will halt the script if there's even a minor error or bad Ajax response without failsafes. Other browsers may not support Javascript in the same ways (looking at you, Internet Explorer 8-)

    When you want more than just JavaScript-powered-pages. If you're using RSS, dynamic XML sitemaps, generated SVG images or generated CSS - you'll be using server-side to generate them because often there's simply no way to dynamically produce them otherwise.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序