不是 PHP 与 JS 的比较:我可以在 PHP 中做任何可以用 JS 完成的事情吗? [英] NOT PHP vs JS Comparison: Can I do anything in PHP that can be done with JS?

查看:37
本文介绍了不是 PHP 与 JS 的比较:我可以在 PHP 中做任何可以用 JS 完成的事情吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在对 (X)HTML 和 CSS 有了一些很好的理解,并计划继续前进.我的下一个选择是 PHP 和 JS(我不知道我是否会最终学习其中之一,但我很乐意).

所以,我需要选择其中之一.我已经了解到 PHP 是服务器端编程,而 JavaScript 是客户端编程,我不是要您为我比较这两者.我想知道的是,我可以在 PHP 中做任何(或大部分)可以用 JS 完成的事情吗?(或者这么说,在服务器端用 PHP 可以做人们用 JS 做的一切吗?)

实例包括,在网页主题中使用 PHP 代替 JS、实时内容显示(如实时博客、实时评论等)、效果等.

这可能看起来很愚蠢,人们在上述所有情况下都使用 JS 肯定是有原因的,但由于我无法(真的)学习这两个,所以我想我应该在这里寻求一些建议.

是否可以使用 PHP 每隔几秒只重新加载网页的一部分(而不是整个网页)?对于我正在计划的实时应用程序来说,这应该足够了.

解决方案

要获得良好的用户体验(动态菜单、ajax、效果等),您需要客户端编程,而对于动态内容,您(几乎总是)需要服务器端编程.

简而言之,两者都需要.

I've now got some very good understanding of (X)HTML and CSS, and plan to move on. My next choices are PHP and JS (and don't know if I'll ever end up learning one of them, but I would love to).

So, I need to choose one of them. I have learnt that PHP is server-side programming and JavaScript is client-side programming, and I am NOT asking you to compare the two of them for me. What I would like to know is, can I do anything (or most of) in PHP that can be done with JS? (or put it this way, can do everything people use JS for, on the server-side with PHP?)

Instances include, using PHP instead of JS in web themes, real-time content display (as in live blogging, live comments etc), effects etc.

This might seem dumb, and there's definitely a reason why people use JS in all the above instances, but since I cannot (really) learn the two of them, thought I should ask for some advise here.

EDIT: Would it be possible to reload only a part of a web page (not the entire web page) every few seconds with PHP? That should be good enough for the real-time application that I am planning.

解决方案

For nice user experience (dynamic menu, ajax, effects, ... ) you need client-side programming and for dynamic content you (almost always) need server-side programming.

In short, you need both.

这篇关于不是 PHP 与 JS 的比较:我可以在 PHP 中做任何可以用 JS 完成的事情吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆