PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>Codetest</title>
</head>
<body>
<?php
session_start();
require_once 'objecttest.php';
$o = new objecttest();
$_SESSION['object'] = $o;
?>
...
Now when I open this in a webbrowser, I get following warnings:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/chroot/home/rond71/public_html/index.php:7) in /var/chroot/home/rond71/public_html/index.php on line 8
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/chroot/home/rond71/public_html/index.php:7) in /var/chroot/home/rond71/public_html/index.php on line 8
Mm, rule of thumb is to put anything header/session related before ANYTHING else
If you're unfamiliar with how HTTP headers work it's pretty cool and interesting to look up.
Start here: http://en.wikipedia.org/wiki/List_of_HTTP_headers and look some of them up. Notably, you want to be looking at the Cookie header regarding your current problem as that's what is giving you the error. Sessions are based on a cookie data (or if cookies are disabled, URL-passed arguments).
I actually haven't used OOP with PHP before but I would imagine you keep them in a separate .php file and use the require_once statement when you need to use them?