Jump to content
Larry Ullman's Book Forums

rob

Members
  • Content Count

    143
  • Joined

  • Last visited

  • Days Won

    16

rob last won the day on January 19 2013

rob had the most liked content!

Community Reputation

53 Excellent

About rob

  • Rank
    Advanced Member
  1. $dbValue = the value stored in the database. <select name="colours"> <option value="blue" <?php if(isset($dbValue) && $dbValue == "blue") echo "selected"; ?>>blue</option> </select> You can use the same principle to pre-populate radio buttons.
  2. For select (drop-down list) you can preset a selection using "selected": <select name="colours"> <option value="blue" selected>blue</option> </select> For radio buttons you can preset a value using "checked": <input type="radio" name="status" value="on" checked>On So you need to compare the value you have stored, against the value of each option and then include selected or checked in the html for that element.
  3. The first thing you need to do is place the instantiation of the SoapClient object within a try catch block. This will help you problem solve the issue you’re having with your script. There is a lot of information online about writing services using PHP. I have no idea where you are in terms of you level of PHP knowledge/learning and I could be doing you a huge disservice by stating get good at searching for information/tutorials online. I had a quick search on google and I got a huge number of useful resources for tutorials; sitepoint seems to have a pretty good 2 part series: creating web services using SOAP and PHP. However, services using SOAP kind of went out of favour back in the day and most developers use REST these days. Personally, I think it’s always good to work through Larry’s books, but after you’ve finished with SOAP I would recommend having a look at creating REST APIs using PHP. There is a tonne of information online.
  4. I think your issue is that you're trying to type hint float on a number that isn't a float: $curtain_price_total. (float)1,234.45 Floats don't have commas. Personally, I would store price as integers in the DB and then format as and when required in your scripts.
  5. Yeah, this was tedious when I first started using vagrant, until I found that you could suspend a guest machine: https://docs.vagrantup.com/v2/cli/suspend.html vagrant global-status is also really handy to manage/see all the guest machines. https://docs.vagrantup.com/v2/cli/global-status.html
  6. I'm Just curious, but is there a reason you've decided not to offer subscription billing. Getting users to log in monthly and make a payment is tedious for them. Why not automatically charge each month and give them the option to cancel at any time?
  7. You’re looking at the wrong script. The issue is with the form script/page where your javascript makes a request to Stripe for a token which it then appends to the form before a post request is made to your payment processor script.
  8. Just in case anyone missed it: https://github.com/blog/1938-git-client-vulnerability-announced
  9. Every coder should be striving to write the most legible code they can, for both themselves and others. Ask yourself how easily and quickly could you read and understand what the code does if you came back to it in 6 months. My view is, always use curly braces. Also, understand that projects often have their own code style rules. I have my own preferences but I’ve found myself having to write code differently because I wanted to contribute to certain open-source projects. I’d recommend having a look at PSR http://www.php-fig.org/psr/psr-1/ “Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.” — Martin Golding
  10. Larry, I think it was more me than the book; not helped by the fact I was reading the kindle version, which isn't always the best for layout.
  11. I'm having trouble understanding/linking the code example to the diagram and definition for the Factory Pattern. abstract class Shape { ... } class Rectangle extends Shape { ... } class Triangle extends Shape { ... } abstract class ShapeFactory { static function Create($type, array $sizes) { switch ($type) { case 'rectangle': return new Rectangle($sizes[0], $sizes[1]); break; case 'triangle': return new Triangle($sizes[0], $sizes[1], $sizes[2]); break; } } } $obj = ShapeFactory::Create($_GET['shape'], $_GET['dimensions']); Must be having an off day because I'm not seeing how the abstract factory class is being extended in the code example. I was unable to find any information in the book explaining the solid arrows or the term concrete, can anyone point me to the right pages, I must be going blind :/ Any help greatly appreciated. edit: ok I think I understand why there was confusion. The UML diagram used in the book is representative of the second reason/example given for using the factory pattern (where a base factory class is extended) but the code example references the first reason given for using a factory class and there is no UML diagram for this.
  12. It's pretty straight forward to achieve. They're simply links with images instead of text. <a href="url_to_somewhere"><img src="icon.png"></a> There are lots of free social media icons available online, so unless you make your own it's just a matter of finding a free style that you like or fits with your overall design.
  13. I've used Twilio with both php and ruby - the api is insanely easy to use. There's some good info in the docs as well as many free tutorials on blogs etc.
  14. Or Curl, not sure it matters which method you use. This looks promising: https://github.com/KnpLabs/php-github-api The docs directory seems to have a pretty good list of examples If you share what you're trying to achieve I/we might be able to be a bit more helpful.
×
×
  • Create New...