Lets jump right in and look at this live demo.
Ok, lets look at the code now. The HTML structure is something like this:
Things are getting weirder.
document.body.style.background = “url(images/middle-bg.jpg)”;
document.body.style.background-position = “center”;
document.body.style.background-repeat = “no-repeat”;
AND IT WAS NOT WORKING!!
I tried variations, searched the forums. There were variations like
Cool, so after some frustrated googling, I found out a way to give spaces in html. Usually if you give lots of space between text in html it shows up as only one space.
To give more than one space, one can use this character:
So if in HTML editor, I write something like:
then in the html page it will show up as:
That’s where comes in handy. So instead of space you’ll have to write something like:
to produce the desired effect.
I was searching for a way to redirect in php scripts to other pages.
<?php echo ‘<script>window.location = “page.html”;</script>’; ?>
It works completely fine. But it isn’t php exactly. So I looked on.
Another option I came upon was the php function header(), which also works fine and has the following format:
<?php header(“location: page.html”); ?>
I had a little doubt though. If I am using the header function in the middle if a php script, then it works fine. But in the php manual of this function http://php.net/manual/en/function.header.php, they clearly state that this function should only be used before any html tag or any php print command. Will look for answers. If the reader knows, he is requested to comment.
>So here’s the difference between the three most often used php functions:
All the above have one common function: they are used to import a code written in an external file. For example in php-mysql applications, a connection needs to be established with the database for carrying out operations in database. This is done via the mysql_connect() function which takes in the parameters of host, user and password. Now this function has to be called in all the files doing mysql tasks. So instead of that, this code is written in a connection.php file and then included in all the other files requiring database connection using the above three functions.
Coming to the difference part, require() as the name suggests is different in the sense that it produces a fatal error if the external file is not found, while include() just produces a warning and moves on with the code. The later may be undesirable at times, so require() is most often used. So in a nutshell, require() makes sure that the file is strictly imported.
require_once() is almost similar to require() except that it checks if the required file has already been imported, in the event of which it skips to the next code. This helps preventing more “redeclared” errors.
Hope this article was useful.