PHP Questions
My site is hosted by Earthlink and their installation of PHP seems to be a little ratty...I'm still learning it right now so I'm no expert. What version of PHP should I expect a good host to be running? Can I install PHP in one of my own directories? I figure not, it seems like a server thing to interpret .php3 file extensions - so I assume it runs to a "main" installation of PHP.
I'm asking because the code
print ("Hello World");
won't work...the Earthlink PHP wants the parenthesis removed.
I just get the feeling that it's a pissy install.
I'm asking because the code
print ("Hello World");
won't work...the Earthlink PHP wants the parenthesis removed.
I just get the feeling that it's a pissy install.
Comments
Originally posted by drewprops
I'm asking because the code
print ("Hello World");
won't work...the Earthlink PHP wants the parenthesis removed.
I just get the feeling that it's a pissy install.
This doesn't neccessarily have anything to do with your ISP's PHP installation. If your site is hosted on a Unix machine, the problem might be that you've created your PHP script on a Macintosh.
Line endings on the Mac are different than line endings on Unix machines, sometimes this causes trouble. If you're using BBEdit you can set the line ending format when clicking "Options" in the "Save File" dialog box.
Greetings,
Daniel
Like this:
<?php
echo("Hello World");
?>
Your linebreak format shouldn't matter except when it comes to strings -- although error reporting usually keys off unix line numbers. The PHP parser ignores whitespace when it comes to code.
Dangit, I hit this problem before when I was doing something else on the site....installing bloxsom I think it was. Should've thought of that already. Okay, time to break out Haxial and try again....and I might want to get BBEdit, about time I tried it again.
Those machines are running UNIX methinks....
Thanks team!
Update: Yes, of course it was the line endings. I'll never fail to forget the crucial technical step at just the wrong time...
What version of PHP are they running? You can put up a page to show you:
<?php
phpinfo();
?>
That will give you all kinds of beefy information about your PHP install...
If there is a problem with your code, typically the resulting page will display an error message (unless they have error reporting turned off, which no hosts I have ever seen do). Do you get an error message?
There technically is nothing wrong with your code, but I personally never use the parenthesis (I typically use echo too, but that is a different story).
print function
EDIT: your php file is a plain text file right? Oh - looks like you solved the issue?
Originally posted by drewprops
dingo kidneys, it's got to be the line endings boys.
Dangit, I hit this problem before when I was doing something else on the site....installing bloxsom I think it was. Should've thought of that already. Okay, time to break out Haxial and try again....and I might want to get BBEdit, about time I tried it again.
Those machines are running UNIX methinks....
Thanks team!
Update: Yes, of course it was the line endings. I'll never fail to forget the crucial technical step at just the wrong time...
drew, I know what you mean. I'm sitting staring at thousands of lines of code and I always forget that one semicolon or curly bracket that screws everything up and I change it all only to find out that I'm just careless as opposed to an idiot.
Down below I've listed a little of the info about the version of PHP that Earthlink has us on at present, note that the first value is the Master Value, the second value is the Local Value. So how old is this car we're driving?
PHP Version 3.0.18
arg_separator
_&
_&
asp_tags
1
1
auto_prepend_file
_
_
auto_append_file
_
_
browscap
_/ms/svc/php/conf/extra/browscap.ini
_/ms/svc/php/conf/extra/browscap.ini
cgi_ext
_none
_none
debugger.host
_none
_none
debugger.port
0
0
define_syslog_variables
0
0
display_errors
1
1
doc_root
enable_dl
1
1
engine
1
1
error_log
_/tmp/php3.err
_/tmp/php3.err
error_append_string
_none
_none
error_prepend_string
_none
_none
error_reporting
7
7
extension_dir
_./
_./
gpc_order
_GPC
_GPC
ignore_user_abort
0
0
include_path
_
_
isapi_ext
_none
_none
last_modified
0
0
log_errors
1
1
max execution time
3600
3600
magic_quotes_gpc
1
1
magic_quotes_runtime
1
1
magic_quotes_sybase
0
0
memory limit
8388608
8388608
nsapi_ext
_none
_none
open_basedir
_none
_none
precision
14
14
safe_mode
1
1
safe_mode_exec_dir
_/usr/local/bin
_/usr/local/bin
sendmail_from
_none
_none
sendmail_path
_/usr/sbin/sendmail -t
_/usr/sbin/sendmail -t
short_open_tag
1
1
smtp
_localhost
_localhost
sql_safe_mode
0
0
track_errors
1
1
track_vars
1
1
upload_max_filesize
2097152
2097152
upload_tmp_dir
_none
_none
user_dir
_none
_none
warn_plus_overloading
0
0
xbithack
0
0
browscap
_/ms/svc/php/conf/extra/browscap.ini
_/ms/svc/php/conf/extra/browscap.ini
y2k_compliance
1
1
highlight_comment
_#FF8000
_#FF8000
highlight_default
_#0000BB
_#0000BB
highlight_html
_#000000
_#000000
highlight_string
_#DD0000
_#DD0000
highlight_bg
_#FFFFFF
_#FFFFFF
highlight_keyword
_#007700
_#007700
Originally posted by drewprops
PHP Version 3.0.18
PHP 3.0??? Hmm... Earthlink must have been outta touch with the rest of the world since the middle ages... Well, actually, that version is about three years old. The current one is PHP 4.3.4 and version 5 is in the final stages of development...
Leave it to the big boys...
sad really
I wonder, does PHP 4.x have a special extension? Like .php3 does? What if I change my call to .php4?
Going to try that now....
But in the meantime, if anybody knows the answer....well, you know.
Edit: Dumbasses. They don't even tell customers that they have v.4.x running ANYWHERE in their documentation. So yes, the .php4 extension worked. We're running:
PHP Version 4.1.2
So good. I just wish they'd update their docs for crying out loud.
For more info you can look here:
register globals
and
predefined variables
Originally posted by The Pie Man
It's good to learn on PHP4 because of the register globals thing I mentioned (deals with variable scope). If you learn, and code, to PHP3, and then move to php4 it is nearly inevitable your app is going to break and you are going to have to go back through and fix your variable scope.
For more info you can look here:
register globals
and
predefined variables
IIRC, register globals was on through version 4.0.6 (maybe longer). When I updated to 4.3.2 all my scripts were broken because the php book I learned with (wrox "Beginning PHP4") didn't even mention the register globals thing. Luckily it was easy to fix but was I freaked out when things stopped working.
I've been going over a couple of good tutorials that used to be hosted on hotwired's web monkey site....they're now on the lycos servers (although some of the links are broken).
My big challenge will be to figure out how best to use PHP to my advantage with my own website. I smell the potential, I just need to visualize how to make it work for me.
If anybody can point me toward some other practical examples of how to use PHP it would be appreciated~
At my company, we have a large number of high profile sites running on PHP. I have seen all types of systems implemented in PHP, ranging from simple scripts to large-scale OOP-based frameworks. PHP is fairly capable and can do most of things you could want it to do.
You could come up with a number of things to do, each of which could be implemented in thousands of ways. Figuring out the best way to do something is perhaps easier said than done -- but this is not new.
Anyhow, here's a short list of examples, general and specific:
* Output the current date/time to your web pages
* Add basic customization and/or personalization of pages based on user information (ie: arranging elements ala Yahoo's home page or displaying "Welcome Xool!")
* Securing access to pages
* Automatic handling of content: page layout, editing, searching, etc. (Don't get me started!)
* Build interactive systems, such as message boards or other community-driven features
* Build an online store, processing CC sales and sending out merchandise
* Power your own Porn site!
* Run a Mac rumor site
* Fight evil
Some things you can't do with PHP:
* Grow vegetables
* Milk snakes
* Bring all the boys to the yard (well maybe, but expect a lot of nerds to come runnin' myself included)
* Birth babies
Not that anybody should make me their special project, but if anyone can answer the following question(s) I'd be grateful. I've encountered some curious things in an example file found on the WebMonkey example...specifically these few lines of code:
# root should be like "/brad/php/example3"
# get directory containing current script
$root = getenv("SCRIPT_NAME");
# get rid of everything after the current directory, which I just so happen
# to know is '/meta'
$root = substr($root,0,strpos($root,"/meta"));
#print "<p>root=[$root]</p>\
";
# docroot should be like "/hot/bab/brad/php/example3"
$docroot = getenv("DOCUMENT_ROOT").$root;
#print "<p>docroot=[$docroot]</p>\
";
The full PHP script can be found HERE.
OKAY!
First off, getenv("SCRIPT_NAME") doesn't give me a filepath as they describe in the preceding comment tag, no, it gives me the root location of the script name, that is:
/root-cgi/php4
Shouldn't I really be doing a : getenv("REQUEST_URI") instead? If I do THAT then I get a path back to the root of my web directory. That seems like what I'm supposed to be looking for...
Again, the full PHP script can be found HERE. This comes from page six of the Web Monkey tutorial!
Any other must-have PHP publications?
My question is what level programmer are you? If you are a novice I can recommend one thing... if an old pro, I could recommend something else.
What I'm trying to do is to go back through my existing site and qualify and categorize my content so that I can re-think how to present the data. I'm probably going to integrate movable type into my new site because I like some of the features I see there. I may integrate the GALLERY software for displaying my portfolio, although I'm considering going with a Flash presentation too...a bit more spiffy and slick looking.
So, right now, I'm at the stage where I'm reverse-engineering some of those old tutorials (as mentioned above) to see how things work....
Originally posted by drewprops
Any other must-have PHP publications?
I like "MySQL/PHP Applications" (or something like that. It's in my computer room and I'm lazy). It's more applied than you probably want but you can find the basics online.
Personally, I'm using php/mysql for running my site. I'm doing a study on the effectiveness of a web-based intervention. It does user tracking, data collection, messaging, etc. All content is in a database and the pages are all based on a template that gets filled in with the relevant data. It's a nice mix of php, html, javascript and css. It wouldn't be possible with any other language.