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 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)