PHP is something I'll have to learn better. It's hard to self teach some of this stuff though! It can take so long to understand it when the syntax of PHP is so weird! Whats with the ? all over? It's just confusing. Just like the ; at the end of each C line.
adept wrote:
PHP is something I'll have to learn better. It's hard to self teach some of this stuff though! It can take so long to understand it when the syntax of PHP is so weird! Whats with the ? all over? It's just confusing. Just like the ; at the end of each C line.
What's confusing about the ; at the end of every line of C or PHP? The following are executed the same in C:


Code:
in
t
x=
12
;
and
Code:
int x=12;
Line returns don't mark the start of new commands, so semicolons have to do the job. You'll understand such things in agonizing depth if you, like me, write a compiler, but you do't need to put yourself through that pain to get the basic concepts.
Yeah Kerm! I knew that! I just forget the darn things all the time! It would be easier if I just didn't have to remember. Razz
adept wrote:
Yeah Kerm! I knew that! I just forget the darn things all the time! It would be easier if I just didn't have to remember. Razz
And which ?s did you mean in PHP? You're probably talking about the ternary, unless you mean $, which precedes the names of all variables. You really should try to work on PHP and C; myself and the other procedural programmers here would be happy to help.
like the
<?php
?>
and the C like syntax.
(whine and complain about easy to get stuff.)
I only know enough PHP to implement some one elses code. No more.
If you want a language where you don't need the semicolons, you could use javascript or flex/actionscript. The <?php ... > just denotes where the PHP scripting block starts and ends (which can also be done with just <? ... >, but is not recommended). You might think about reading through this to help out.
As for learning C, I wouldn't suggest starting with C. I would suggest something like Python or even C#. Just because there are some lower-level concepts you have to deal with in C that can confuse a beginner. I'm sure people will argue with me on that point, though.
KermMartian wrote:
The following are executed the same in C:


Code:
in
t
x=
12
;
and
Code:
int x=12;
If you can include whitespace inside keywords (int) I'd find a new compiler if I were you. Smile

I've always found using ; to terminate statements a bit silly in "C-style" languages. I've always preferred the attitude some BASIC dialects have; line breaks terminate statements (this is the norm), but you can include multiple statements on one line with : or split a single statement across multiple lines with _ (these are the exception).
Oh sorry, I failed the pedantry of my example, but you see what I was trying to do there. Smile Python does a similar thing; it assumes that each line return terminates the statement on that line and requires no semicolons (although if you type them out of force of habit it will just ignore them). If you want a multiline statement, you just terminate each line with a backslash to escape the line return. An added bonus, subsequent lines in a multiline statement don't have the strict whitespace requirement, so you can align them as you desire for more attractive code.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement