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 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊