FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

javascript php html styling and good practice.

 


nisibdv
I am learning javascript and am very happy with the new possibilities for web development this programming lenguage offers. A month before I also learned php. I am doing now some forms for my (previouly static boring) webpage. I am very happy with all the new possibilities opened. But have a big problem to organize my work.

I come from a C formation. Having been programming in that very organized and strongly typed language, I feel something uncomfortable with the mixture of programming languages needed to make a decent webpage.

I would appreciate very much if someone can guide me to find some material related with the styling and organization of web-programming.

For example, I had lot of troubles with quotes and double quotes in the mixture of languages. When an echo with single quote contains a string that needs a single quoted string inside you have to make very awkward things for this to work.

Thank you for any help on that.
djclue917
Are you referring to something like a server-side code (e.g., PHP, Python, etc.) + (X)HTML + JavaScript combination? If yes, then one method to 'keep things clean' is to separate the JavaScript from the markup (HTML) as much as you can. With the server-side code + HTML, you can't really do much about it, as far as I know.

By the way, are you using some kind of framework for your web apps?
alalex
Another good practice is instead of "reinventing the wheel" as some people would say, rely on libraries and open source scripts. This way you end up saving up time and you have a very tidy programmed site.
For php check out in this forum for topics like "best php frameworks" or that sort of stuff to decide which one you would like to learn,
For javascript use stuff like prototype, mootools, jquery... But of course there are way too many...

So this way you will see how you really save up a lot of time. One of the good things about using frameworks and libraries is that later on you will be able to install plugins, so that the capabilities of it never stop growing. Wink
BlueVD
nisibdv wrote:

I come from a C formation. Having been programming in that very organized and strongly typed language, I feel something uncomfortable with the mixture of programming languages needed to make a decent webpage.

Well, if you take some time to learn them, you'll find out it's quite easy, and both php and javascript can be used by strong-type fans Smile
As to the mixture... I'm sure you had to work at one time or another with XML... That should get you started with HTML. As for php, it's similar to C & C++ in some aspects. And so is JavaScript.
nisibdv wrote:

I would appreciate very much if someone can guide me to find some material related with the styling and organization of web-programming.

For example, I had lot of troubles with quotes and double quotes in the mixture of languages. When an echo with single quote contains a string that needs a single quoted string inside you have to make very awkward things for this to work.
Thank you for any help on that.

Escaping special chars is something quite common:
Code:

$string1='escaping single quotes is done by adding a \\ in front of the quote mark like \' for example';

You'll notice that I used the \ char to escape the single quote. Also when using the \ char itself, you must escape it, so you use \\ (similar to the pascal way of escaping the single quotes by using '')
Also, note the difference between single quotes and double quotes:
Everything between single quotes it taken literaly so to say: '{$text} and some stuff'
Lines between double quotes are parsed to check for special language constructs;
For example:
Code:

$text='foobar';
$ex1='{$text} and some stuff';
$ex2="{$text} and some stuff";
echo $ex1; //produces {$text} and some stuff
echo $ex2; //produces foobar and some stuff

You can read more on php.net...
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.