Jump to content

Recommended Posts

I following along in this book named Apache,Mysql and PHP Web Development for Dummies.

I followed and wrote out the code for viewing todays date .
I saved it as todaysdate.php in a directory named phpfiles.

when I go to that directoy and double click on the todaysdate.php it wants to open it with gedit.
if I change the name to todaysdate.html it will open in firefox but not show the date or do what it's suppoed to do.
I'm used to being able to open an html file in the editor and change it, save and refreash the webpage and see the changes.

how does one do this with a .php file?
Here's the php file in case that helps.
More than likly I just need to go back a few chapters and re-read something hu?

<html>
<head>
<title>Today's Date</Title>
</head>
<body>
Greetings! Today is
<?php
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
print=" $month $mday, $myear\n";
?>
</body>
</html>

I saved it as todaysdate.php
Link to comment
https://forums.phpfreaks.com/topic/11179-viewing-todaysdatephp/
Share on other sites

You cannot execute PHP files the way you do with HTML files, ie double click it and it'll open up in the browser. As PHP is a server-side lanaguage it requires a server that is configured to execute any .php files with the PHP intepreter. Now in order to do this you need to open up a browser and type in [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] you should see list of files and folders now click the file you want to execute, or typeing the actuall name of the script like so: [a href=\"http://localhost/todaysdate.php\" target=\"_blank\"]http://localhost/todaysdate.php[/a]

NOTE: the url [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] will only work if you have a server setup on your computer. Now with the Dummies book you have there should be chapter or an apendix section that tells you how to setup a server on your computer.
Link to comment
https://forums.phpfreaks.com/topic/11179-viewing-todaysdatephp/#findComment-41814
Share on other sites

[!--quoteo(post=379988:date=Jun 4 2006, 11:36 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 4 2006, 11:36 AM) [snapback]379988[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You cannot execute PHP files the way you do with HTML files, ie double click it and it'll open up in the browser. As PHP is a server-side lanaguage it requires a server that is configured to execute any .php files with the PHP intepreter. Now in order to do this you need to open up a browser and type in [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] you should see list of files and folders now click the file you want to execute, or typeing the actuall name of the script like so: [a href=\"http://localhost/todaysdate.php\" target=\"_blank\"]http://localhost/todaysdate.php[/a]

NOTE: the url [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] will only work if you have a server setup on your computer. Now with the Dummies book you have there should be chapter or an apendix section that tells you how to setup a server on your computer.
[/quote]

Ah, that makes sense. I do have Apache set up on here and Mysql.
Now I remember a section where your php files need to in a certain location. DOH!

thanks
Doug
Link to comment
https://forums.phpfreaks.com/topic/11179-viewing-todaysdatephp/#findComment-41836
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.