opening files

Posted on 2006-04-21
Last Modified: 2010-04-06
For record...

if (!($f=fopen("welcome.txt","r")))
exit("Unable to open file!");

Can I open a file to read or write or read and write with an error message for a not opened file and without ")))"?

For record...

   "Unable to open file!"

Can I open a file the way I wrote?
Question by:locke2005
    1 Comment
    LVL 4

    Accepted Solution

    $fp = fopen("welcome.txt,"r") or die("Unable to open file!"); //checks for read access, dies if not able to open
    $fp = fopen("welcome.txt,"w+") or die("Unable to open file!"); //checks for read-write access, dies if not able to open

    is this what you are looking for ?


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now