| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Why am I getting this; php | |
|---|---|
| Tweet Topic Started: Nov 14 2005, 12:32 AM (530 Views) | |
| dbzlotrfan | Nov 14 2005, 12:32 AM Post #1 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
<?PHP Function some_thing () { $num = 18; } echo Function some_thing; ?> is the code, and the error: Parse error: parse error, unexpected T_FUNCTION in C:\Program Files\xampp\htdocs\PHP_BOOK\PHP\What.php on line 5 I know it's probably not the right function syntax. but it's a try.
|
![]() |
|
| Jory | Nov 14 2005, 03:22 AM Post #2 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Well.. because its all wrong. ![]()
Would work.
Would also work.
Is a third option. To make a function give a result, you must eigher tell the function itself to echo it, or return it, put it in a var and echo that. Now, here is something that might work, but I'm not sure about it.
|
![]() |
|
| dbzlotrfan | Nov 14 2005, 07:24 PM Post #3 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Your first, didn't work. Just got a blank page. |
![]() |
|
| Dennis | Nov 14 2005, 07:31 PM Post #4 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
What are you trying to do? I think the correct syntax to echo 18 would be this:
Qj almost got it right. You need an echo, not a return. The return is for something different. |
![]() |
|
| solinent | Nov 14 2005, 09:16 PM Post #5 |
![]()
Member
![]() ![]() ![]() ![]() ![]()
|
<?php Function return_18() { return 18; } echo return_18(); ?> ^^ Will work. |
![]() |
|
| Jory | Nov 15 2005, 05:21 AM Post #6 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
>_< I ur teh stupid. |
![]() |
|
| Seth | Nov 15 2005, 12:00 PM Post #7 |
|
I has a pony
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
No, your examples are much more valid than Dennis', even though you mixed up a call. Functions should NEVER output data as a result of running them. They should ONLY return data. It is very bad programming practice to have a function output. Have it return a result and then you can handle it how you need to. Functions exist only as black boxes to put data into and get results out of. Nothing more. |
![]() |
|
| Dennis | Nov 15 2005, 12:58 PM Post #8 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
>,< *Dennis writes it down. Sorry. |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
10:29 AM Jul 11
|



![]](http://b1.ifrm.com/0/1/0/p601690/pipright.png)




10:29 AM Jul 11