本文整理汇总了PHP中CS50::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CS50::init方法的具体用法?PHP CS50::init怎么用?PHP CS50::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CS50
的用法示例。
在下文中一共展示了CS50::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ini_set
<?php
/**
* config.php
*
* Computer Science 50
* Veritalks
*
* Configures app.
*/
// display errors, warnings, and notices
ini_set("display_errors", true);
error_reporting(E_ALL);
// requirements
require "helpers.php";
// CS50 Library
require "../vendor/library50-php-5/CS50/CS50.php";
CS50::init(__DIR__ . "/../config.json");
// enable sessions
session_start();
// require authentication for certain pages except those listed below
if (!in_array($_SERVER["PHP_SELF"], ["/login.php", "/logout.php", "/register.php", "/main_page.php", "/about_us.php", "/ask_question.php", "/give_advice.php", "/upvote.php", "/user.php", "/academics.php", "/social_scene.php", "/student_life.php", "/real_world.php", "/prospective_students.php", "/financial_aid.php", "/academics_user.php", "/social_scene_user.php", "/student_life_user.php", "/real_world_user.php", "/prospective_students_user.php", "/financial_aid_user.php", "/academics_upvote.php", "/social_scene_upvote.php", "/student_life_upvote.php", "/real_world_upvote.php", "/prospective_students_upvote.php", "/financial_aid_upvote.php"])) {
if (empty($_SESSION["id"])) {
redirect("main_page.php");
}
}
示例2: ini_set
<?php
/**
* config.php
*
* Computer Science 50
*
* Configures app.
*/
// display errors, warnings, and notices
ini_set("display_errors", true);
error_reporting(E_ALL);
// CS50 Library
require "vendor/library50-php-5/CS50/CS50.php";
CS50::init(__DIR__ . "/../../server/config.json");
// enable sessions
session_start();