The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > Web Programming > PHP


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags: ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 10-17-2007, 11:55 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,110
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Icon4 Please Help with PHP!!!

I received this message:

Quote:
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/5/d158572600/htdocs/fb/broadcast/webtest/testScript.php on line 3
Here's the code that I have:

testScript.php
PHP Code:
<?php
class {
    
public function A1() {
        print 
"TEST A1";
    }
    
    
public function A2() {
        print 
"TEST A2";
    }
};
?>

test.php
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TESTER</title>
</head>
<?php
include 'testScript.php';
print 
"TEST: " A1();
?>
<body>
</body>
</html>

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 10-18-2007, 12:19 AM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 417
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
I copy-and-pasted your testScript.php file and it worked fine. Maybe you have a typo in that file that's not present here?

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 10-18-2007, 07:08 AM
tj111 tj111 is offline
Novice
Join Date: Oct 2007
Posts: 2
iTrader: (0)
tj111 is on a distinguished road
I'm not sure exactly what your trying to do. I'm new here, so I'm not sure if my response is something your already very familiar with. PHP: Visibility - Manual

Even if the function is public, you still have to create the class before the function is created (the parser doesn't parse a class until it is created).
PHP Code:
$A = new A(); 
Once it's created, you can call the function:
PHP Code:
print "TEST: " $A->A1();
//Output == TEST A10 
The "+" is a mathematical operator, and since the string "TEST:" has no integral value, it evaluates to 0. Use "." instead for strings.

PHP Code:
print "TEST: " $A->A1();
//output == TEST A1TEST: 
Since the function prints an output, and the function call in a print statement, it won't work like expected.
PHP Code:
$A->A1();
//output == TEST A1 
So the whole script would be
PHP Code:
<?php
class {
    
public function A1() {
        print 
"TEST A1";
    }
    
    
public function A2() {
        print 
"TEST A2";
    }
};
$A = new A(); 
$A->A1();
//TEST A1
?>
Once again I don't know your level of knowledge with PHP, so if this is something your already familiar with, let me know.



__________________
PHP Code:
if (stristr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
    
$user 'noob';
    
session_destroy;
    
header("Location:http://firefox.com");


Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following 2 Users Say Thank You to tj111 For This Useful Post:
HelloWorld (10-18-2007), TeraTask (10-18-2007)
  #4 (permalink)  
Old 10-18-2007, 07:54 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,110
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Thank you all for the help, but I'm trying to figure out why does this error always come up:

Quote:
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/5/d158572600/htdocs/fb/broadcast/fbapi_php4_restlib.php on line 485
It seems that there's nothingw rong in line 485 of that document:

PHP Code:
  public function data_setUserPreference($pref_id$value) {
    return 
$this->call_method
      
('fb.data.setUserPreference',
       array(
'pref_id' => $pref_id,
             
'value' => $value));
  } 
But I'm just wondering why does that error always showed up, this time I'm using the PHP4 API, but it still pop up an error for some reason, btw, I didn't write this API.. the website that I want to create the application for is the one who wrote this...

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 10-18-2007, 08:15 AM
tj111 tj111 is offline
Novice
Join Date: Oct 2007
Posts: 2
iTrader: (0)
tj111 is on a distinguished road
I thought public/private/protected declarations weren't introduced until PHP 5? I could be wrong though. See the first comment (by "Aouie Web_Form_Aouie.net") at PHP: Classes and Objects (PHP 4) - Manual for a workaround.

__________________
PHP Code:
if (stristr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
    
$user 'noob';
    
session_destroy;
    
header("Location:http://firefox.com");


Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to tj111 For This Useful Post:
HelloWorld (10-18-2007)
  #6 (permalink)  
Old 10-18-2007, 08:25 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,110
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Yes that is right, I fixed the problem by deleting all of the public/private/protected keywords... Now new problem come up, it says that I cannot instantiate isterxmlsimplexmlimpl

do you guys know anything about this thingy..? I tried to do a google search on it, but I don't have time right now, I'll probably fix it later, I just need to find the class and include it in this file... thanx a lot guys!

the API did say:

PHP Code:
include_once 'simplexml44-0_4_4/class/IsterXmlSimpleXMLImpl.php'
however, I don't see that the file is located in that specific folder... lol..

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #7 (permalink)  
Old 10-18-2007, 09:22 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 615
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
Quote:
Originally Posted by HelloWorld View Post
however, I don't see that the file is located in that specific folder... lol..
If its not in that folder than it will not be able to communicate with the file will it, i suggest you put it in there lol.
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 11:26 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50