02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

132<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

■ Note Initializing $C as an empty array is a safeguard against any tainted pieces of data being stored in $C <strong>and</strong><br />

defined as constants. This is a good habit, especially when dealing with sensitive data.<br />

Save this file. If you’re not using XAMPP or if you’ve modified the default database credentials, you’ll<br />

need to substitute your own host, username, password, <strong>and</strong> database name in the code.<br />

Creating an Initialization File<br />

At this point, your database credentials still aren’t stored as constants. You’ll be using an initialization<br />

file to h<strong>and</strong>le this.<br />

An initialization file collects data, loads files, <strong>and</strong> organizes information for an application. In this<br />

example, it will load <strong>and</strong> define all necessary constants, create a database object, <strong>and</strong> set up an<br />

automatic loading function for classes. Other functionality will be added later on as it becomes<br />

necessary.<br />

Create a file called init.inc.php, <strong>and</strong> place it in the core folder (/sys/core/init.inc.php). Inside,<br />

add the following:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!