A lot of PHP Questions

He has: 3 posts

Joined: Feb 2005

First, i'm planning to use preg_match, ereg_match, etc..

I think "preg" and "ereg" uses something like in the Apache's RewriteModule the "[0-9]" something like that... Do you know a tutorial that will easily teach me on how to do that?

Second, I'm planning to use Apache Rewrite. But I really don't know how to use. Do you know a tutorial that will easily teach me on how to do that?

Third, while openning some php scripts, I didn't get the meaning of example:

<?php $sample1->//some string here ?>
'What does it mean? I didn't master the array functions of PHP. Do you know a tutorial that will easily teach me on how to do that?

Fourth, I really need to master PHP easily. Do you know a tutorial that will easily teach me on how to do that?

Fifth, I'm planning to use MySQL. But It's really difficult for a beginner like me to learn that. Do you know a tutorial that will easily teach me on how to do that?

Sixth, About offline debugging of my website, I have Apache 1.3, and the latest version of PHP. that's why before uploading my files, I know that they will work because i debug them offline. My computer will act like a server, but offline. Now, how can I use MySQL? The download size is very big! and also, I remembered, I tried it, 29 MB, and with PHPMyAdmin. Is there any other way to download a LITE version of mysql to be used for offline debugging purposes? and also, is the a stand alone program that will let me manage and edit databases?

I hope that you will be able to answer all of my questions.

Oh yeah, another one, how can I create a PHP script that will be easily readed by people?

Another one:
Now, in PHP i know there's microtime, srand, float, array_rand, arrays, foreach, or any other loop functions. i'm really confused. Please help me!

Opera 8 Beta 2 (build 7483) º Windows XP Professional SP2 º Pentium III 702MHz º 10GB Hard Drive º 128MB RAM º 17" Monitor º CMI8738 Sound Card º 28.8Kbps º ISP Reloaded Prepaid Internet Card º Trillian 2.013 Pro º Ad Muncher 4.61 (build 16020) BETA
My Website | My Blog

View my Image signature

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

1 and 2:
preg, ereg and Apache's Rewrite utilise regular expressions (the [0-9] stuff). The difference is preg uses Perl regular expressions, whereas ereg uses POSIX-Extended regular expressions. My guess is Apache Rewrite (mod_rewrite) uses POSIX regex (which may or may not be Extended) or similar.

3:
That particular line doesn't make much sense. You're obviously supposed to replace "//some string here" with some relevant string -- hard to say what exactly that should be without knowing the context of the example. The $foo->bar syntax is used to access methods and variables (members) within an initialised class/object. In my example, class Foo, member bar; in yours, class Sample1, member "some string".

4 and 5:
Write scripts, refer to the manual constantly, and read its user comments. Google for tutorials -- there are too many to link. But I'll mention Kevin Yank's series on PHP and MySQL as they are a nice intro to working with both.

6:
Well there is SQLite, but I doubt that's what you're looking for. I'm afraid most net-based software distributors use at least 56k or higher as their lowest client bandwidth consideration, so 29mb is acceptable. As general advice, it might be an idea to get a better connection if you're planning on working the web.

There are standalone apps offered by MySQL for administration:
Administrator - download
Query Browser - download

Another one 1:
You want to know how to make your code readable, or your script's output readable? Develop and use a reasonable code style (be consistent!) if you want to keep code readable, perhaps stick to the PEAR standard. And properly comment your code -- this is very important. If you want your output to be more readable, that's a matter of styling it with XHTML and CSS.

Another one 2:
Sorry, this makes no sense. What's precisely is your question regarding those functions?

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Abhishek's reply says about all I would say, and I most certainly agree with the suggestion of writing scripts as the best way to master it. I have been working with PHP for about 4-5 years now, and there are still new things I learn every week (especially now that about 90% of my work is programming PHP).

I guess it really depends on the person, but I love the PHP manual. I sometimes go in there looking for functions I have never used and read about them, and several times have come away with new and/or better ways to do things I did another way before.

As for the size of the download of mySQL, if you are really insterested in learning it, it is well worth the time to download. Learning a language (like anything) requires a commitment of your time to dedicate to it. (and in the case of downloading a file, you can do other things during this time).

With so many systems now coming with a cd burner standard, maybe find a friend with a faster connection and ask them to download it and burn it to CD for you.

Abhishek: thank you for the link on the PEAR standard. I had never seen that before.

Consistant code formatting is essential in debugging! On this forum and one stictly for php i go to, I see people post some of the most messed up code asking for help. The first thing I do is copy it into an editor and clean up the formatting. Makes a BIG difference.

As Abhishek said, comment your code! you may write soemthing today that 3 months from now you find you want to modify, and you can spend twice as much time if you don't know what you were thinking when you wrote it!

I wish you well on your road to programming! It can be fun and addicting!

-Greg

CptAwesome's picture

He has: 370 posts

Joined: Dec 2004

There are lots of good tutorials. Even if something doesn't even remotely apply to something you are doing, it'll give you a good idea of syntax, and the process you go through when writing the code. The place I started was Webmonkey

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.