php开发

VSCode中PHP开发实战指南

基础

php概述

🍑 定义
PHP(全称:PHP:Hypertext Preprocessor,即"PHP:超文本预处理器")是一种通用开源脚本语言。
是一种创建动态交互性站点的强有力的服务器端脚本语言。
相关内容参考网页:https://www.runoob.com/php/php-intro.html

vscode运行php文件

🍑 php解析器下载 与 apache配置
php8.38.3.26)
下载安全版的,VS16 x64 Thread Safe (2025-Sep-23 18:57:54)
下载参考:https://www.cnblogs.com/ckoo/articles/18075078
配置参考:https://blog.csdn.net/sinat_41883985/article/details/106061125#:~:text=%E6%9C%AC%E6%96%87%E8%AF%A6%E7%BB%86%E4%BB%8B%E7%BB%8D%E4%BA%86%E5%A6%82%E4%BD%95%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E6%90%AD%E5%BB%BAApache%E4%B8%8EPHP%E7%8E%AF%E5%A2%83%EF%BC%8C%E5%8C%85%E6%8B%AC%E4%B8%8B%E8%BD%BD%E3%80%81%E9%85%8D%E7%BD%AEApache%E4%B8%8EPHP%EF%BC%8C%E8%AE%BE%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%EF%BC%8C%E9%83%A8%E7%BD%B2PHP%E9%A1%B9%E7%9B%AE%EF%BC%8C%E4%BB%A5%E5%8F%8A%E5%90%AF%E5%8A%A8Apache%E6%9C%8D%E5%8A%A1%E7%9A%84%E5%85%A8%E8%BF%87%E7%A8%8B%E3%80%82,%E7%89%B9%E5%88%AB%E5%BC%BA%E8%B0%83%E4%BA%86%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%9A%84%E4%BF%AE%E6%94%B9%E8%A6%81%E7%82%B9%EF%BC%8C%E5%A6%82Apache%E7%9A%84httpd.conf%E4%B8%8EPHP%E7%9A%84php.ini%EF%BC%8C%E4%BB%A5%E5%8F%8A%E5%A6%82%E4%BD%95%E6%B7%BB%E5%8A%A0%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%E3%80%82

🍑 vscode下载插件
php server 和 PHP debug

🍇 测试执行test.php出现问题

Serving project
From v3.0.0 onwards, PHP server will open the server URL inyour default browser. You can set a different one by changingthe 'phpserver.browser" setting
// 意思是:如果使用php server 3.0.0以上的插件,启动项目,可以自动实现默认浏览器打开服务;
// 如果不想使用默认浏览器打开,可以通过phpserver.browser 自定义设置;

vscode+php

vscode创建php项目

vscode启动php项目

参考:https://www.php.cn/faq/1423445.html

方式1:使用vscode内置的服务
在终端窗口,在项目路径下,执行:php -S localhost:8000

vscode+redis+php

下载pecl 链接:https://pecl.php.net/package/redis/6.2.0/windows
安装php_redis.dll

在这里插入图片描述
在这里插入图片描述

修改:
extension=php_redis.dll

html+php方式

参考:https://blog.youkuaiyun.com/m0_61505785/article/details/142477128

实战

php server不受信任

在这里插入图片描述
在这里插入图片描述

点击“工作区信任”,选择左侧“在受信任的窗口中”

php登录页面新增二次验证

原始分析

<?php
require_once 'includes/all_fns.php';
?>
// 引入一个包含通用函数的 PHP 文件(可能是数据库操作、工具函数等)
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
  <head>
    <title>登录</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="/resource/res/favicon.ico" rel="bookmark" type="image/x-icon" />
    <link href="/resource/res/favicon.ico" rel="icon" type="image/x-icon" />
    <link href="/resource/res/favicon.ico" rel="shortcut icon" type="image/x-icon" />

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Management System for Unicom SMS Template Manage" />
    <meta name="keywords" content="mobile internet financial" />
    <!-- Bootstrap -->
    <link rel="stylesheet" href="/resource/css/bootstrap.min.css">
    <link rel="stylesheet" href="/resource/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/resource/css/animate.css">
    <link rel="stylesheet" href="/resource/css/font-awesome.min.css">
    <!-- Custom stylesheet -->
    <link rel="stylesheet" href="/resource/css/<?php echo $GLOBALS['main_css']?>">
		// 动态输出全局变量中定义的主样式表文件名(方便灵活切换样式)
		// $GLOBALS 超全局数组

    <!-- jQuery -->
    <script type="text/javascript" src="/resource/js/jquery-3.1.1.min.js"></script>
    <!-- Bootstrap -->
    <script type="text/javascript" src="/resource/js/bootstrap.min.js"></script>
    <!-- Custom JS -->
    <script type="text/javascript" src="/resource/js/commutils.js"></script>
      <style>
          html.gray {
              filter: grayscale(100%);
              -webkit-filter: grayscale(100%);
              -moz-filter: grayscale(100%);
              -ms-filter: grayscale(100%);
              -o-filter: grayscale(100%);
              filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
              -webkit-filter: grayscale(1);
          }
      </style>
  </head>
  <body>
    <iframe id="preview" src="/resource/<?php echo $GLOBALS['login_html']?>" frameborder="0" width="100%"></iframe>
    // 动态输出登录表单的 HTML 文件路径(登录表单内容通过 iframe 嵌入)
    <footer id="footer" class="navbar-fixed-bottom row-fluid login-bottom-nav">
      <div class="navbar-inner login-bottom-nav">
        <div class="container">
          <p class="text-orange text-center center-block"><?php echo $GLOBALS['footer_name']?></p>
          // 动态输出页脚显示的名称(如公司名、系统名等)
        </div>
      </div>
    </footer>
    <script>
      $(document).ready(function () {
          // 重置登录iFrame的位置和大小
          function fix_height(){
            $("#preview").attr("height", (($(window).height())) + "px");
          }
          $(window).resize(function(){ fix_height(); }).resize();
      });
    </script>
    <!-- FOR IE9 below -->
    <!--[if lt IE 9]>
    <script src="js/respond.min.js"></script>
    <![endif]-->
  </body>
</html>

vscode-php代码实现跳转

🍉 下载 PHP Intelephense 插件

最后

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值