PHP pages go in the same directory locations as html pages, ~/public_html on stulogin.dcs.shef.ac.uk

You cannot use PHP from the normal DCS web server (www.dcs.shef.ac.uk) - if you try to then it will download the file rather than execute it.

Student Web server

This is the easiest development environment and should normally be used by student projects. Visible only from university campus

You can create a simple test file e.g. “hello.php” in your public_html directory, containing the text “<?php echo 'Hello PHP World'; ?>”. View the file at http://stuwww.dcs.shef.ac.uk/people/A.User/hello.php (replace A.User by your email address, dont include from the '@' symbol!))

To view the PHP settings, include a line “echo phpinfo();” in your hello.php file, e.g. http://stuwww.dcs.shef.ac.uk/people/G.Wilson/hello.php

Notes

The PHP installation is configured to be secure, and there are a couple of common problems you might encounter if you are used to developing on a less secure servers.

By default, error messages do not appear. You can turn them on with a line “ini_set(“display_errors”, 1);”

Global session variables are not automatically passed from the session file, and you need to extract them manually:

Before After
session_register(“userName”); print $userName=]; $userName = “pat”; session_start(); session_register(“userName”); if (isset ($_SESSION['userName'])) {$userName = $_SESSION['userName'];} print $userName; $userName = “pat”; $_SESSION['userName'] = $userName;

Similarly, form variables are not automatically passed into the PHP variables, so you must do this manually.

Before After
print “you typed: ”.$text; print “was check box 2 selected? ”.$cb[2]; if (isset($_POST['cb'])) {$cb = $_POST['cb']; } if (isset($_GET['text'])) {$text = $_GET['text']; } print “you typed: ”.$text; print “was check box 2 selected?”.$cb[2];
using_php.txt · Last modified: 2021/02/19 14:54 by ac1mde
Public Domain
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0