gpt4 book ai didi

php - 我应该学习和使用什么才能成为 PHP 和 Python Web 开发专家?

转载 作者:太空宇宙 更新时间:2023-11-04 08:22:40 25 4
gpt4 key购买 nike

我将只展示一些代码来展示我如何使用 PHP 进行 Web 开发。

<html>

<head>
<title>Example #3 TDavid's Very First PHP Script ever!</title>
</head>
<? print(Date("m/j/y"));
require_once("somefile.php");
$mysql_db = "DATABASE NAME";
$mysql_user = "YOUR MYSQL USERNAME";
$mysql_pass = "YOUR MYSQL PASSWORD";
$mysql_link = mysql_connect("localhost", $mysql_user, $mysql_pass);
mysql_select_db($mysql_db, $mysql_link);

$result = mysql_query("SELECT impressions from tds_counter where COUNT_ID='$cid'", $mysql_link);
if(mysql_num_rows($result)) {
mysql_query("UPDATE tds_counter set impressions=impressions+1 where COUNT_ID='$cid'", $mysql_link);
$row = mysql_fetch_row($result);
if(!$inv) {
print("$row[0]");
}
}

?>

<body>
</body>
</html>

就是这样。我这样写每个文件。最近,我学习了 OOP 并开始在 PHP 中使用类和对象。

我听说那里有很多 PHP 框架。他们说必须使用这些库。但我觉得他们只是让事情变得复杂。

无论如何,这就是我一直在进行 Web 开发的方式。现在,我想改善这一点。并使其特化。我也想转向 Python。我搜索了 SO 文件,发现每个人都在推荐 Django。但是,任何人都可以告诉我 Python 中的 Web 开发是如何工作的吗?

user (client) request for page ---> webserver(->embedded PHP interpreter) ----> Server side(PHP) Script ---> MySQL Server.

现在,是否有 python 解释器而不是 PHP 解释器,而不是 php 脚本有 python 脚本,它包含 HTML 和 python(嵌入在某种 python 标签中)。 Python 脚本连接到数据库服务器并获取一些将打印为 HTML 的数据。还是在 python 世界中有所不同?

Django 是不是类似于 PHP 的框架?不使用 Django 就不能在 python 中编写一个代码。因为,我从来没有遇到过没有django的帖子

请给我一些启动。

最佳答案

PHP 是为制作网页而构建的,因此很多基础设施已经为您设置好了。 Python 更像是一种通用脚本语言,因此您需要一些额外的基础设施来处理请求和生成网页。

Python 有多种框架。 Django是最受欢迎的但是Pylons是另一个不错的。看看this list of Web Frameworks for Python :

A web application may use a combination of a base HTTP application server, a storage mechanism such as a database, a template engine, a request dispatcher, an authentication module and an AJAX toolkit. These can be individual components or be provided together in a high-level framework.

These are the most popular high-level frameworks. Many of them include components listed on the WebComponents page.

  • Django (1.1 Released 2009-07-29) a high-level Python Web framework that encourages rapid development and clean, pragmatic design

  • Grok (1.0 Released 2009-10-07) is built on the existing Zope 3 libraries, but aims to provide an easier learning curve and a more agile development experience. It does this by placing an emphasis on convention over configuration and DRY (Don't Repeat Yourself).

  • Pylons (0.9.7 Released 2009-02-23) a lightweight Web framework emphasizing flexibility and rapid development. It combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python Web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility but only if you need it. Out of the box, Pylons aims to make Web development fast, flexible and easy. Pylons is built on top of Paste (see below).

  • TurboGears (2.0 Released 2009-05-27) the rapid Web development megaframework you've been looking for. Combines CherryPy, Kid, SQLAlchemy and MochiKit. Create a database-driven, ready-to-extend application in minutes. All with designer friendly templates, easy AJAX on the browser side and on the server side, with an incredibly powerful and flexible Object Relational Mapper (ORM), and with code that is as natural as writing a function. After reviewing the website check out: QuickStart Manual

  • web2py (1.72.3 Released 2009-11-10) All in one package with no further dependencies. Development, deployment, debugging, testing, database administration and maintenance of applications can be done via the provided web interface. web2py has no configuration files, requires no installation, can be run off a USB drive. web2py uses Python for the Model, the Views and the Controllers, has a built-in ticketing system to manage errors, an internationalization engine, works with MySQL, PostgreSQL, SQLite , Oracle, MSSQL and the Google App Engine via an ORM abstraction layer. web2py includes libraries to handle HTML/XML, RSS, ATOM, CSV, RTF, JSON, AJAX, XMLRPC, WIKI markup. Production ready, capable of upload/download of very large files, and always backward compatible.

  • Zope (2.10.7 Released 2008-10-25, 2.11.2 Released 2008-25-10, Zope 3.4.0 Released 2009-01-29) Being the grandaddy of Python web frameworks, Zope has grown into a family of frameworks over the years. Zope 1 was released in 1999. Zope 2 is both a web framework and a general purpose application server, today it is primarily used by ContentManagementSystems

关于php - 我应该学习和使用什么才能成为 PHP 和 Python Web 开发专家?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2476335/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com