Jump to content

Nameless12

Members
  • Posts

    244
  • Joined

  • Last visited

    Never

Everything posted by Nameless12

  1. My point was not about there being more of a demand for php books, there is because more non programmers start out with php over asp due to its availability. There is more demand for php books because there are more beginners than experts. I am not sure if I explained wrong or if you read what I said the wrong way. The bottom line is the reasons for what is for on a book shelf have nothing to do with what language is better, not a damn thing.
  2. that does not mean what you said about the ASP vs PHP Books does not means anything at all. The reason for this is a marketing strategy and has more to do with target audience than anything else plus the fact php is free easy and available means beginners are more likely to want to learn it. Most content everywhere tv\books\movies\news\media usually targets stupid people it is rare when you find content targeting experts\intelligent people the reason is a numbers thing, if you market a product at beginners there is just a greater potential for potential customers than if you create a product targeted at experts\people that are experienced to some degree.  If you like the media and the content it chooses to put out there, that is your choice and is not  my point. My point is that the reason for this has very little to do with what language is actually better with maybe an exception of the fact it is free and that is only because the fact its free makes it more available.
  3. I could give you a long list of ways you could improve it, but all of those ways would require you to learn additional stuff. In short I think you need to learn more before you consider doing something like this. I cant tell you how many times I have changed the design of my structure in terms of code\directory structure and individual classes. It happens a lot, the more you learn the more you want to go back and change things. The thing is when you create a product you should only go back and change it in a way that leaves it backwards compatible. I don't think it is possible for you to keep it backwars compatible unless you learn more before doing lots of the code. Your functions\class directories are empty, these directories should have the most files in them. even if they are simple functions such as printr() <-- same as print_r but  pre tags inside the function or br(3) <-- prints 3 <br /> tags. It does not matter how simple these functions are the simpler the better, but most of the "framework\library" size should be made up of the files in these directories. You should also not force people that use the framework to use your own database structure or session_start(). I dont use session_start() the way you have used it in your project because I dont like the way it functions when it comes to session expire times and I really hate its lack of security. But by using session_start in the way you have you have remove all choice from the people who would use your framework. Unless you have fixed the session handler in a way that improves the security and other issues it has then you should not force it on people. You should also not force people to use your own database and database tables in a framework. Once a framework adds a database it has usually turned into some form of content management. And I hope you realize I am also referring to mysql as well as your db.sql file. What happens if someone wants to use microsoft sql server? will they have to install mysql + your table structure too. I have a feeling this will sound overly critical, I just feel you are wasting time that would be better spent filling up the class\function folders. After you create a lot of classes and functions that will be more of a framework than your current project. And please, shorten the directory names or use an underscore to separate the words. oh and one last thing I think you should make a conscious decision about framework vs content management because I see this going towards content management but you say you want to do a framework, figure out what it is you really want to do.
  4. There is a bug when you login and click logout it says "you have been successfully logged out but in the top right hand corner it says you are logged in until you refresh the page
  5. or as an alternative you can setup mod rewrite so any file request in the web directory that is not an image\css\js file is redirected to index.php (this is why i dont see it as a problem at least in my case, different people with a different setup should make sure they lock\hide\protect the dir just as you say)
  6. I have said some stuff that was not entirely accurate about *.tpl probably beucase I never took the time to do a lot of tests. I just included a plain text file with <?php echo 'hello world!'?>, it works. It makes sense and I feel stupid for even questioning if it is possible because include\require treat anything included as php so *.tpl will work
  7. http://www.corephp.co.uk/archives/19-Prepare-for-PHP-6.html [quote] Farewell <% They will remove support for the ASP style tags, but the PHP short-code tag will remain (<?) - so to those on php general who reckon the short-tag is 'depreceated' - hah! [/quote]
  8. I do use normal tags for all my code except views at the moment I have been building a framework that has very few views and the views are not final. They are just there as a make shift environment for testing. When it comes to making applications with this framework I consider the choice to use short or normal tags as a design choice for that project, the way i am doing templating I like choosing servers is as much a design choice as anything else, I made the design choice long ago I would code for php5, not php4. my code will break on 95% of servers for this reason, but it was a design choice. The sort of thing applies here. I find this subject of short tag vs normal tag to be somewhat stupid because most hosts dont support php5. I heard something like 5% of the php servers have php5.. going by this someone might choose not to program for php5.. but choosing your server is as much a design design decision as any other
  9. I am aware of <?= ?> and <?php echo ?> provides an alternative.. it is really trivial and is just a matter of developing for the server you are stuck with. It is something where I do not think it is worth worrying about as I prefer to host my own servers and most hosting companies have short tags turned on. by <?=?> I didnt mean the short tags the way It may have come off, I just meant that you can do stuff like <?php if ()?> <?php endif;?> <?php echo 'a'?> But that said I will always continue to develop for a short tag environment but keep in mind 100% of my libraries use <?php tags, I am aware it is best practice but as long as short tags are there I will use them and I do not see this as a problem In answer to business man its not template.tpl.php, it is template.tpl with no php. The idea is not to have one template for your entire site but to make the site composed of multiple templates. for example I have a logged_in.tpl and logged_out.tpl for my login script. The main advantage is debugging and tidy code, you can do the same thing with an include but it will be lacking debugging and will be messy
  10. I never said they didn't have their place but in the context of this conversation and on a technical level python is better than both is better than these languages. I am aware each language has its place, if I wasn't I would not use php. 
  11. [quote author=businessman332211 link=topic=123685.msg512014#msg512014 date=1169613311] Hmm, very interesting points. I have yet to see a templating engine I like, I thought about building my own, but I can't think of anything but the same type of syntax I see for smarty.  I used it once, said I hated templating engines, never second thought one again.  Is yours personal or can I see it in action, like see the file's for it, or something as an example, so I might be able to create my own.  I don't like seing file's named .tpl, and .tpl.php that part annoyed me, and the stuff I see in some of hte applications.  They have a .tpl file with all this thrown in code, that (to me), look stupid, bulky, and hard to read.  Me being a PHP programmer, looked at the php code they called a templating engine and had to spend 30 minutes before I understood any of it.  So far I hate them, do you  mind sharing what you have with me. [/quote] Make your own. It does no need a template sytnax. What you dont realize is you can do <?if():?> <?elseif():?> <?else:?> <?endif;?> along with <?foreach($data as $key => $value):?> <b><?=$value?></b> <?endforeach;?> because php can be used in this way there is no need for special syntax if you read my last post again that will sum up what i think a template engine should be used for the only time special syntax should be used is in languages that dont come with built in tags like php has Try making your own but to make one worth using you are going to have to use oop here is a simple example [code] class Template {   private $_dir;   private $_data = array();   public function __construct($dir = null)   {       if ($dir)           $this->_dir = $dir;       else           $this->_dir = 'some/dir';   }   public function assign($name, $value)   {       return $this->_data[$name] = $value;   }   public function display($template)   {       require $this->_dir . '/' . $template;   }   public function debug()   {         echo '<pre>';           print_r($this->_data);         echo '</pre>';     }      public function __get($name)     {         if (isset($this->_data[$name])             return $this->_data[$name];     } } [/code] the above is a very rushed and untested example, my own version is probably 200 lines. There is also one other advantage to making your own. It is easy to make Template_Abstract then extend it Template extends Template_Abstract this gives you a nice clean slate to add functionality. EDIT:: about what you said about hating naming them *.tpl that is just a nameing convention. You do not need to call them tpl files you can call them *.mytemplatefile if your server is configured to allow *.mytemplatefiles to execute php code
  12. Learn basic hacks and you will learn how to defend your self.
  13. I believe the official mysql site has some tools to help with what you are trying to do.
  14. Your script is vulnerable to sql injection
  15. [quote author=redbullmarky link=topic=123685.msg511918#msg511918 date=1169597346] CI and Cake both handle templating in the same way...Neither by default use what you would call an 'engine' (in the sense of using stuff like {VAR} and {NAME} etc - both use PHP natively as their template syntax. Nameless12, that's some good advice dude. I probably do get carried away a little when trying to get a particular point across. On the other hand though, Frameworks and MVC make a fantastic couple, and a framework can easily be designed AROUND the MVC pattern. As far as I'm concerned, MVC is more than just a pattern - it's an entire structure. Patterns to me are the more trivial things that complete specific tasks that would in turn become PART of an MVC setup. mod_rewrite just kinda helps things along in terms of getting everything going through a single point of entry to keep things all nice and compact. So i'm not actually stating that all of this is essential/a requirement of MVC, but it sure helps alot in the grand scheme of things, IMO of course. cheers [/quote] I disagree. It is hard for me to sum up why I disagree in a short way I guess the closest I can come is I feel mvc is an important cog in the machinery that is application development but it is not the machine, it is just one of many cogs that help the machine keep functoning. seriously ask your self what have you used more? mvc or the factory pattern? I use this as an example as most of my code in my current project has very few views as most of it is libraries\framework. Until a webpage uses more views than its libraries\models and such than mvc will never be more than just a pattern. I do agree it is an important design pattern but most design patterns are important, I Just feel that it is just a design pattern like any other and that people here that are confused about what it actually is should learn what each of the patterns is and learn them one at a time instead of saying all the most useful patterns are called "mvc" doing that will just create confusion and make it hard for them to put stuff into context. I do understand where you are coming from but to me its just a design pattern.
  16. Templating engines come in all different types of flavors. I have a feeling you are referring to template engines such as Smarty?? I hate them to. Mine gives me a few advantages they are mostly to do with scope and the ability to type $this->debug() on any page to see what data I have access to. Also the files are loaded through a central point allowing me to prefix the template_directory. Also it allows me to easily add ob_start() require $template_dir . $template_file; return ob_get_clean() The above code is far from how my source code looks but the point is it handles buffering for me easily. The idea of the template engine can have many different implementations all I use it for is the actual file loading, debugging and manipulating scope in order to keep things tidy. I hate templating engines that have their own language such as smarty as it is not needed. It is also personal preference to some degree, a simple include $dir . 'template.tpl' will work just fine but I think the idea of having an object to handle the loading and debugging is good for code reuse and is more robust when working on larger applications. And just to clear something up no framework will ever force you to use a template engine as there is no way to remove the include\require so there is no way to force it on you. The only time I think It can sort of be pushed on you is when developing in languages such as python that dont allow you to do things like  -->  <b><?=$text?></b>  <--- without a template engine.
  17. php is still useful to learning gtk but dont do it to create apps in php the way you might be thinking now. GTK for python and php why not the same is so similar that you will be able to move from one to the other with relative ease after you know one of them.
  18. You are all getting confused with mvc I think. The kind of talk I am seeing looks like that about frameworks but MVC is not a framework pattern it is more of a 3 step process that frameworks have made their own implementation. The stuff you are all saying about directory structure and mod_rewrite may be good and may be a good approach to solving many problems but that is not mvc that is mvc with a dozen other design patterns thrown in. You need to take it one step at a time I think and trying to copy frameworks the way it sounds like is not the solution because you just wont be able to put all the patterns into context straight away. I know you are new to oop, very new. But you should learn it and learn how to make a template engine or something just because it compeletly separates the controller from the view if you use a templating engine. Consider the followng $r = $db->query('select * from data'); $t = new template(); $t->assign('my_database_data', $r->fetchAll(PDO::FETCH_OBJ)); $t->display('template.tpl'); in the above code you can think of the database object as a model and the script controlling it is a controller because it is controlling it. The template engine is sending the data to a template and the template will be separate from the controller, hence the "view". Just learn one pattern at a time the frameworks you are all talking about and trying to copy are using many patterns, mvc is just one of many.
  19. Sorry to say but this idea is horrible. The reason is ajax is javascript, you cant learn ajax with out learning javascript and the php side of ajax is done in php. If phpfreaks wants to expand I think it should not focus on ajax but instead javascript. It is impossible to learn how to do ajax with out learning javascript.
  20. I know there are timestamps in some areas but if you look at the individual posts and stuff they have no time stamp, can you change this.
  21. Does anyone know short tags are no longer default in php5.20?
  22. I dont know if I understand you correctly But what I would do for my project is create a log table in your database that stores the name of the page loaded along with timestamp\ipaddress\page_name and other useful data. Once you have this data you can write functions like user_last_page_viewed() last_page_viewed() these functions should return a page_id or page_name. and you should be able to use this data the way you want if i have understood you correctly EDIT:: I said what i was most familiar with but you can easily do the same with sessions. At the bottom of your page store the page_name or page_id inside $_SESSION['last_page_clicked'] = 'current_page_name';
  23. <?=new html_table_pager('select * from users :limit', 'postgres', 'header goes here')?> The above is my html pager. The first arg is a query or an array of data followed by the database i want to use if i want to use one. My DB Api is configured for multiple dbs so thats why I need that and the header goes here is the table header and that is optional. The table pager extends the html_table and html_table extends html_abstract. html_abstract pretty much turns html into a big object allowing me to use inheritance wherever I want. The pager object is actually separate from the table object that autogens tables based on input. The pager object returns $pager->link; $pager->data; My html_table_pager is just passing the data into the table_autogen and the link into $table->add_footer($pager->link); The table autogen has a mode option and if this mode option is turned on (it is by default) it will show the name of the keys in a header that is below the main header. If the row count is equal to 1 it will appear on the left hand side instead of the top. I was thinking of adding a link there to sort my results easily but because the data is indirect I could only reverse sort or order what is currently inside the table. The problem with this is the data in the table is only what is needed for that one page. Because my pager slices the data up into the limits assigned by my pager script. For example the pager will show 5 results for example 1 2 3 4 5 but the total results might be 100, but if i try to reverse it it makes it 5 4 3 2 1 instead of 100 99 98 97 96 95 I think it will be a big pain to fix this an work around it to add the feature. I am wondering if anyone has done this before and how they did it. And also if anyone thinks I am making a big mistake by leaving the feature out. I will find it kind of annoying leaving it out as i am a perfectionist. But it will just be to much of a head ache to fix I think. Any Ideas?
  24. [code] foreach ($file as $key => $line) { if ($line == 'some_string') {     $save = $line;     $line_num = $key; } } [/code] is the above any help?
  25. I was just trying to explain to him in one line how line numbers are created
×
×
  • 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.