473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem using require in a class

34 New Member
Expand|Select|Wrap|Line Numbers
  1. <?
  2. class LibertyReserve {
  3. require ('config.php');
  4. public function sendMoney($amount, $currency=$DEFCurrency, $target, $memo) {
  5. require('config.php');
  6. $content = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');
  7. for ($i=0; $i!=$length;$i++){
  8. $RandomString_Each = rand (0,61);
  9. $RandomString .= $content[$RandomString_Each];
  10. }
  11. $rid = $RandomString;
  12. $request = '
  13. <TransferRequest id="' . $rid . '">
  14. <Auth>     
  15. <ApiName>' . $APINAME . '</ApiName>
  16. <Token>' . $auth . '</Token>
  17. </Auth>
  18. <Transfer>
  19. <TransferType>transfer</TransferType>
  20. <Payer>' . $LRAC . '</Payer>
  21. <Payee>' . $target . '</Payee>
  22. <CurrencyId>' . $currency . '</CurrencyId>
  23. <Amount>' . $amount . '</Amount>
  24. <Memo>' . $memo . '</Memo>
  25. <Anonymous>false</Anonymous>
  26. </Transfer>
  27. </TransferRequest>
  28. ';
  29. $url = 'https://api.libertyreserve.com/xml/transfer.aspx?req=' . $request;
  30. $response = file_get_contents($url);
  31. echo $response;
  32. }
  33. }
  34. ?>
  35.  
I got:
Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting T_FUNCTION in C:\inetpub\wwwroot\LRapi\class\LibertyReserve.clas s.php on line 3

Note: I am requiring 2 config.php, it is NOT a mistake, because i can't use var. in "sendMoney" if i require the file outside "sendMoney" function. And the another config.php have contain $DEFCurrency and $auth.
Sep 4 '10 #1

✓ answered by kovik

It's a syntax error. It's also pretty obvious.

You are attempting to require a file in a space that is reserved for the definition of member variables and methods. Move it to the outside of the class.

Also, instead of requiring the file again, why don't you just try using the global keyword to define the variables you need in your method's scope?

2 1935
Kong Chun Ho
34 New Member
Anyone have solution?
Sep 4 '10 #2
kovik
1,044 Recognized Expert Top Contributor
It's a syntax error. It's also pretty obvious.

You are attempting to require a file in a space that is reserved for the definition of member variables and methods. Move it to the outside of the class.

Also, instead of requiring the file again, why don't you just try using the global keyword to define the variables you need in your method's scope?
Sep 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Powell | last post by:
I traced the problem to what I believe is when I use the included content library script into the viewinterns.php page. This script will repeatedly instantiate a DateGroupHTMLGenerator class...
4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
1
by: Christian Eriksson | last post by:
Hi! I have a problem using the environment variable LD_LIBRARY_PATH in my perl script. Everything works fine when I set it at the command prompt and then runs my perl script like this: ...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
1
by: wadefleming | last post by:
I have the following code which I am having trouble with. The problem is detailed in the comments near the end. Constants.cs: -------------- namespace MyApp.Const { public class Const {...
2
by: parseint | last post by:
Hi, Im trying to send a files using a HTTP POST request in my Window Application. I also have a progressbar that is being updated whil uploading. I have managed to send a file using HTTP PUT,...
0
by: muntyanu | last post by:
Hi All, I got permission issue when accesing network files from the application that was started using Process component. Actually I have my .NET windows service running. From this service I...
1
by: Wang E | last post by:
I've been working on an online judge(for ACM/ICPC) using C#.Programmes submitted by users can now be compiled,and it's the problem to judge.I use the Process class in C#,and my thread is as...
3
by: Franky | last post by:
Been having a problem using a treeview. Work great the first time the form containing it is entered but not the second time. Took a while to create a small sample that exhibits the problem, but...
2
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name)...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.