Jump to content

ManiacDan

Staff Alumni
  • Posts

    2,604
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by ManiacDan

  1. Is there any particular reason you WANT to do this? All date/time functions accept a timestamp as an argument. If one is not provided, it uses "now." You could write your script to have a test flag which will override the value of every date function.
  2. It's only available in PECL (which I don't have installed) so you'll have to check the behavior of it yourself for user-defined functions. There is also rename_function, which may work for you.
  3. The actual answer to your question: You appear to only write to one file, which is: $Fnm = "./include.php"; $inF = fopen($Fnm,"w"); Put the folder definitions in the $Fnm and you should be fine. You may have to make the directory first. Other comments: Whatever you're doing here is probably wrong, I bet you can do this much easier another way if you tell us why you need to do this.
  4. Why not just go to youtube?
  5. I disagree. PHP was not meant to be a strictly typed language, and a lot of things wouldn't work in their current state if it was. There are many other languages that follow suit. I don't think it is a huge deal. As long as you understand the difference between == and ===, you shouldn't ever have any problems. I'm with you. Most of the complaints about PHP stem from either (a) not understanding loosely typed languages or (b) not understanding symbol tables. PHP is loosely typed. == is not ===. If you really really care about data types (like in this specific scenario), use ===. Otherwise, == is magical. Empty strings, zero, negative one, false, empty objects, empty arrays, whatever. "not something" a very powerful concept.
  6. Use PHPMailer, it handles most of the hard parts for you. There are tutorials available for it. Be sure to set the FROM and REPLY-TO headers using the built-in functions.
  7. Barand is correct about strpos, but strstr works differently. Strstr returns the matched string. All three of these examples worked for me: php > $a = '123@456'; php > $b = '123@ 456'; php > $c = '123 @ 456'; php > var_dump(strstr($a, '@') == true); bool(true) php > var_dump(strstr($b, '@') == true); bool(true) php > var_dump(strstr($c, '@') == true); bool(true) php > var_dump(strstr($a, '@')); string(4) "@456" php > var_dump(strstr($b, '@')); string(5) "@ 456" php > var_dump(strstr($c, '@')); string(5) "@ 456" I'm not sure why you think it wasn't matching with the space after it for strstr. Either way, strpos !== false is what you want. Make sure you realize that !== is correct, and != is incorrect. === and its counterpart !== are required here, not ==.
  8. I'm not really frustrated, I just honestly have no idea what you're even doing anymore. You have two scripts now which do two things you may or may not need. I don't know what you're using which requires tab delimited strings rather than a normal, sane data structure like an array, but good luck with it. If this is still not what you needed, go back and state the problem more concisely. What do you have? What do you need? Why do you need it that way?
  9. What is the actual problem then? What is "the formatting part"? You said: Did this have nothing to do with CSV output? Are you just looking to replace a single \n with \t as long as there aren't two \n\n? If that's the case: $str = str_replace("\n\n", "__DOUBLE_NEWLINE__", $str); $str = str_replace("\n", "\t", $str); $str = str_replace("__DOUBLE_NEWLINE__", "\n\n", $str);
  10. "Address" is spelled wrong, that just bothers me because you'll never know the names of your functions if they're all spelled wrong. Define all your functions in the global scope at the top of the file (or in a separate include file) so you know they're always accessible.
  11. 1) You can use a database just like you'd use a text file, using a database gets rid of your delimiting problem entirely, just insert it into the database. Whether or not the paste into a textarea is irrelevant, you can insert anything you want into a database. 2) Encoding something using base64 (or whatever) will also avoid your encoding problem. You said you were having issue with \n\n and \t and how they'd interact with the csv format. Just keep them in whatever format you want, and encode them. the encoded data will be compatible with csv format, and the decoded data would still have newlines and tabs however you'd like them.
  12. Post the solution so that others may benefit. Also, mark it as "solved." The answer, for anyone who comes across this, is: 1) Use alternate delimiters. Regular expressions don't have to start and end with /. You can use any non-alphanum character, like # or even {}. 2) Escape the slash, like so: /.+\/.+/
  13. fputcsv deals with a pre-existing resource handle, not a pre-existing file. Using fopen you can create a new file. The correct answer is "use a database." If you can't for whatever reason, you can encode the questions and answers so they're sure not to contain quotes or whitespace. base64_encode every field and you won't have a problem.
  14. Sending mail that isn't spam is a very difficult process. Depending on the volume your answer is anything from "use PHPMailer and set the reply-to header" to "hire a spam mail expert and establish business relationships with the 10 largest email hosts"
  15. It's your page, not mine. Change the colors, make it bold, whatever. You "do it with CSS" the same way you do anything with CSS: give it a special class. This...makes no sense, but again, it's your site and not mine. How do you determine which page you're on? However you determine that (url, filename being called, a variable called $page), check that against the nav items you're printing when you print them. If the page you're on matches the nav item you're about to print, make it a different color or size or whatever.
  16. No reason to make that a PHP extension, it would be too slow to parse a PDF every time. It should be a standalone application. However, PDF creation tools are pretty locked down to Adobe products. Maybe their PDF library actually does that.
  17. Initialize $arg2 to some value that's impossible for it to be. If you expect $arg2 to be a positive integer, make its default -1. That's how it was done before "null" became a language construct.
  18. This is the only way my suggestion will work. Inside your nav include file, when you print the menus, change the color of the menu item which corresponds to the page you're on.
  19. Re-create the form in HTML by hand. Use the PDF as your design guide, don't use it as the actual basis for your website.
  20. You're also not really doing functions right. You pass in a variable that's never used and then use globals to pull in two more that ARE used. Pass variables into functions, you defeat their entire purpose using global. Also, it's possible that field in that row is just empty, or non-printable characters like an HTML tag.
  21. Wherever you output the menu, check to see which page you're on and change the color of that menu item.
  22. You can't edit PDF files easily, that's the whole point of them. You certainly can't edit PDF files using a rich text browser editor. What are you trying to accomplish here?
  23. And for a little bit more information, I wrote a whole article on the == operator
  24. Please note that this is not a board for "give me the coding." We're here to help you learn, not to do it for you. Also, please try to include a better subject next time. Only one person is helping you because you posted a thread titled "need PHP coding help" in a forum called..."PHP Coding Help."
  25. I like eclipsePDT, though it's slow. I'm actually using Geany now and I love it, but as far as I know it's linux-only.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.